0

To make the list unmodifiable in a derived class and to the external world, I understand that it must be declared private and final. How would it be modified to make it immutable even within the same class without using the unmodifiableList method? I must clarify that this is for a theoretical scenario asked during an interview.

I was told that it has something to do with not allowing changes to hashCode(), but can someone please give me a concrete solution? By extension, I also want to know how to make any (custom) object immutable.

Dharini
  • 1
  • 1

0 Answers0