Use following static methods :
- Collections.unmodifiableCollection(Collection coll)
- Collections.unmodifiableMap(Map map)
- Collections.unmodifiableList(List list)
- Collections.unmodifiableSet(Set set)
If you perform add or remove operation on a read-only collection, it will throw UnSupportedOperationException.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.