[] list syntax can give ClassCastExceptions
Brought to you by:
bonniot
This line of code compiles and gives a
ClassCastException at runtime.
LinkedList<String> list = [ "1","2"];
Exception in thread "main"
java.lang.ClassCastException: nice.lang.rawObjectArray
It should either turn the rawObjectArray into a
LinkedList via new LinkedList(Collection), make it as a
LinkedList to begin with, or give a compile time error.