I know that it is a trivial matter but I want to ask this question. Suppose that I have a get method that returns an ArrayList of objects. First do we have to returns a copy of it? If so, does it have to be a deep copy of the ArrayList? Do we still need to do a deep copy when the objects inside it are immutable? If we use this type of constructor
ArrayList<T> arr = new ArrayList<>(collection);
then are the elements of the array copied or they still point to the old values? Thanks