Why does Arrays.asList(…).toArray().getClass() give different results in JDK 8 and 9? [duplicate]
The List type returned by asList is Arrays$ArrayList. The toArray method in JDK 8 on that class is: @Override public Object[] toArray() { return a.clone(); } But in JDK 9+ it is: @Override public Object[] toArray() { return Arrays.copyOf(a, a.length, Object[].class); } In both cases a String[] is passed to asList, but in the JDK … Read more