Entry is a non-static inner class. This means that it is included in the scope of the general parameters of the outer class. Each time you simply write an unqualified Entry inside TestClass , it implicitly means TestClass<K,V>.Entry , which is a parameterized type! As you know, you cannot create arrays of a parameterized type, for example. you cannot make new ArrayList<String>[5] .
Usually a workaround for creating arrays of parameterized type is to instead create an array of the raw type, i.e. new ArrayList[5] , or an array of type with a wildcard parameter, ie new ArrayList<?>[5] . But in this case, what is the raw type? The answer is that you must explicitly qualify Entry with the outer type of the outer class:
entry = new TestClass.Entry[10];
or alternating with a wildcard parameter:
entry = (Entry[])new TestClass<?>.Entry[10];
source share