Immutable List with nCopies()

The nCopies() method of Collections class returns an immutable object of List. The immutable object cannot be modified. It is read-only. If tried to modify, the JVM throws UnsupportedOperationException. Following is the method signature static List nCopies(int n1, Object obj1): Returns an immutable list containing n1 elements of the object obj1. That is add() method …

Immutable List with nCopies() Read More »