...

/

Making Collections Unmodifiable

Making Collections Unmodifiable

Let's discuss how a collection can be made unmodifiable.

We'll cover the following...

Let’s say we have created a collection where we have added some important data. We want others to read this data, but they should not be allowed to modify the data in this Collection. The Collections class provides certain methods that can be used to make our Collection unmodifiable. These methods return a collection in which if someone tries to add or remove an element, then UnsupportedOperationException is ...