Java/JVMTechnology

Why is Generic Array Creation not Allowed in Java?

To understand this topic let us directly start with an example. List<Integer> arrayOfIntegerList[] = new ArrayList<>[10]; // compile time error !! You will find that a simple statement like this will not even compile because the Java compiler does not allow this. To understand the reason, you first need to know two arrays are covariant and generics are invariant. […]