Creating an array of generic type objects is not permitted in Java. The array does not has enough type-information to check for ArrayStoreException and ClassCastException based on the type of it at runtime. That's the reason why. However, the first paragraph of Item 24 in Effective java says,
When you program with generics, you will see many compiler warnings: unchecked cast warnings, unchecked method invocation warnings, unchecked generic array creation warnings, and unchecked conversion warnings. The more experience you acquire with generics, the fewer warnings you’ll get, but don’t expect newly written code that uses generics to compile cleanly.
What is generic array creation warning? if we are to create an array of generic type object, we must get a compile error. why warning? It should the error.
Thank you in advance.