The first one is assigning a list to list
, but this list will be based on the array being used as the base ( meuArray
), so the list
is only one reference to the list.
The second does the same with the constructor argument, but the constructor of ArayList
has the function of copying the content it receives as a list, so it will take the received reference and copy each element to a new list, so it is very but it will have an isolated list.
The question is whether to keep the same list or not. The difference is in the constructor and not in the asList()
method. The first does not build anything, it just uses what has already been built by asList()
, and this method usually does not build anything strong either, it even builds a list object, but it will reference the array of direct form and will not make any copies.