I\'m new to Java and am trying to understand why the first code snippet doesn\'t cause this exception but the second one does. Since a string array is passed into Arrays.as
No need to cast manually. This simple code may help you,
List stuff = new ArrayList(); String line = "a,b,cdef,g"; String delim = ","; stuff.addAll(Arrays.asList(line.split(delim)));