People say that asList
method convert the array into list and its not copying, so every change in \'aList\' will reflect into \'a\'. So add new values in \'aLis
asList returns a fixed-size list, so that you cannot add new elements to it. Because the list it returns is really a "view" of the array it was created from ('a' in your case), it makes sense that you won't be able to add elements - just like you can't add elements to an array. See the docs for asList
This List implementation you receive from Arrays.asList
is a special view on the array - you can't change it's size.
The return type of Arrays.asList()
is java.util.Arrays.ArrayList
which is often confused with java.util.ArrayList
. Arrays.ArrayList
simply shows the array as a list.