title: All HashMap type values erased in generic class?
body: <p>Why does the following not compile? The compiler gives an error for the <code>+</code> sign in the print line.</p>
  
  <pre><code>public class Test&lt;T&gt; {
    HashMap&lt;Integer,Integer&gt; m = new HashMap&lt;Integer, Integer&gt;();
    public static void main(String[] args) {
      Integer zero1 = 0;
      Integer zero2 = 0;
      Test t = new Test();
      t.m.put(1,zero1);
      t.m.put(2,zero2);
      System.out.println(t.m.get(1)+t.m.get(2)==t.m.get(2));
    }
  }
  </code></pre>
  
  <p>I understand type erasure, but m is a <code>HashMap&lt;Integer,Integer&gt;</code>, it should not depend on the type <code>&lt;T&gt;</code> at all. Why is the compiler rejecting this? Removing <code>&lt;T&gt;</code> in the first line allows compiling, but I don't see why this shouldn't work as well.</p>
  
  <p>Is this a compiler bug or is there any logic behind such behavior?</p>