ArrayList pass value problem

ArrayList is an object type, the record about the problems encountered by value

ArrayList assumed that two types of values ​​a and b, a has a value, b value no, trying to copy all of the value of a b.

If you use

1 b = a;

Assignment, the address will be a assigned to b, when we modify b, the data will also be in a modified, because they are the same address references.

So to use the following methods to operate

1 b = new ArrayList<>(a);

This will assign a value to b, rather than assign the address of b.

Guess you like

Origin www.cnblogs.com/QY-admin/p/12615836.html