I understand about type erasure surrounding generics, but I was still surprised to find that this code generates no error:
public class MyClass {
private final HashMap<ClassA,ClassB> hashMap;
public MyClass() {
this.hashMap = new HashMap<>();
}
}
Mostly, I use the Java Standard version of Eclipse with Java 1.6, and the generic types are auto-filled when I select the auto-completed constructor name. I'm now using the J2EE version of Eclipse and Java 1.7, and they're not. The code compiles and it's fine. It's completely redundant information, so I don't see why it should be required. But it just feels wrong that you don't have to put it.
Why is this not required, or am I totally missing something here?