What's the difference in these two ways?
-
List<Integer> list1 = new ArrayList<Integer>(Arrays.asList(ia));
-
List<Integer> list2 = Arrays.asList(ia);
Note that ia refers to integer array
I have come to find that some operations are not allowed for list2. Why is that the case? How does it get stored into the memory?
If I shuffle lists, ist1 doesn't change the original array, but list2 does. So list2 is confusing for me.
How does the ArrayList being upcasted to list is different than creating a new ArrayList?
list1 differs from (1)
ArrayList<Integer> list1 = new ArrayList<Integer>(Arrays.asList(ia));