Returning const reference of an arraylist
I really admire java features and I don't want to give up using it for the next problem: I have a class that might be inherited, and inside of it is a private ArrayList arr; So the setter function is ok , but the getter function return arr; returns the reference to that variable which anyone capable of editing that whole array which I don't want and private wouldn't make any sense ! In C++ I would just return const arr; and it would return constant reference to the variable. I so much need the variable not to be cloned or manually copied because there are so many calculations that require to