I was looking through the Java libraries and I saw this code in the Arrays.java:
public static <T> List<T> asList(T... a) {
return new ArrayList<>(a);
}
And I am just wondering that isn't it suppose to be:
return new ArrayList<T>(a);
My guess is that it is calling this method in ArrayList.java:
public ArrayList(Collection<? extends E> c) {
elementData = c.toArray();
if ((size = elementData.length) != 0) {
// c.toArray might (incorrectly) not return Object[] (see 6260652)
if (elementData.getClass() != Object[].class)
elementData = Arrays.copyOf(elementData, size, Object[].class);
} else {
// replace with empty array.
this.elementData = EMPTY_ELEMENTDATA;
}
}
}
What does the question mark mean at Collection?