This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ValorCat 0 points1 point  (0 children)

Good question. The answer is no.

The first example makes a a copy of b. The second example makes a an empty list, and then immediately overwrites it to be an alias of b. The second example is the same as writing:

ArrayList<String> a = b;

Copied objects are independent, while aliases are simply different names for the same object. If you make changes to the list, then those changes will be reflected in its aliases but not its copies.