Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arrays.asList() Confusing source code

According to this source code for the Arrays class, the method asList passes an array to the constructor of new ArrayList. But there is no such constructor. Doesn't varargs generate an array, so how is this possible?

Here is the asList source:

public static <T> List<T> asList(T... a) {
    return new ArrayList<T>(a);
}
like image 611
rubixibuc Avatar asked Aug 18 '12 04:08

rubixibuc


1 Answers

java.util.Arrays.ArrayList is a different class than java.util.ArrayList.

like image 56
Paul Bellora Avatar answered Oct 21 '22 08:10

Paul Bellora