title: What mean <K,V> before HashMap<K,V>? Generics in Java
body: <p>I'm reading the book Effective programming in Java and during the reading I met such a code snippet:</p>
  
  <pre><code>public static &lt;К, V&gt; HashMap&lt;K, V&gt; newInstance() {
      return new HashMap&lt;K, V&gt;();
  }
  </code></pre>
  
  <p>what does the expression <code>&lt;K, V&gt;</code> between static and <code>HashMap&lt;K,V&gt;</code> how it is called and works? I've heard about generics, but I do not know them well and I want to know why it's impossible to write some like:</p>
  
  <pre><code>public static HashMap&lt;K, V&gt; newInstance() {
      return new HashMap&lt;K, V&gt;();
  }
  </code></pre>
  
  <p>why before <code>HashMap&lt;K, V&gt;</code> I need to write <code>&lt;К, V&gt;</code>?</p>