Why I can initialize ArrayList, like this:
ArrayList x = new ArrayList(Arrays.asList(1,2));
But got Error whe
Because Arrays.asList(1,2) will implicitly return a List.
Arrays.asList(1,2)
List
You can fix this by using the following idiom:
ArrayList x = new ArrayList(Arrays.asList(1l,2l));