Today, I faced an odd situation of generic array creation of Java 7. Take a look at following two statement.
Map<String, String>[] hashArr= new HashMap[2]; // Compiles
Map<String, String>[] hashArr= new HashMap<>[2];// Does not compile
Here first statement compiles without diamond operator, if I put diamond operator or generic type at right side than it does not compiles. I faced same situation for all generic type, List<T>
, Set<T>
Can anyone tell me, what is the reason for not compiles second statement?