Justin Allen wrote:My second question is about copy Constructors...
...how would the implementation be, would it be this:
It depends on what you want. That gives you a shallow copy, which can be dangerous. It means that
values is referencing the same list as is referenced by the original object. If you make any changes to that list then both objects will see the change.
You can make a deeper copy by copying the list -
ArrayList has its own copy constructor, so you can use that:
Now
values is referencing a copy of the list, so you can change them independently. But the
Objects within the list are still the same
Objects. For a deep copy you'd have to go through each of those and copy them as well. Whether that's necessary depends on what the objects are and how youre using them.