Thursday, June 3, 2010

How to make read only objects - Collections

The java.util.Collections class contains the following methods to make objects read only.

1. unmodifiableList(List list)

Returns an unmodifiable view of the specified list.

2. unmodifiableMap(Map m)

Returns an unmodifiable view of the specified map.

3. unmodifiableSet(Set s)
Returns an unmodifiable view of the specified set.

No comments:

Post a Comment