In Arrays.java file. The method asList is defined as below.
@SafeVarargs
public static <T> List<T> asList(T... arr) {
return new ArrayList<>(arr);
}
Here the ArrayList constructor is invoked with an Array.(arr), new ArrayList(arr). But there is no constructor in ArrayList class which accepts Array as argument.Array class is in Collections FrameWork but doesn't implement Collection interface. The constructors in ArrayList are
ArrayList()
ArrayList(Collection<? extends E> c)
ArrayList(int initialCapacity)
can someone explain what is happening there?