micharg
Friday, 10 June 2011
How can a method return an immutable (read-only) collection (list,map,set)?
return Collections.unmodifiableList(list);
return Collections.unmodifiableMap(map);
return Collections.unmodifiableSet(set);
References
http://download.oracle.com/javase/1,5.0/docs/api/java/util/Collections.html#unmodifiableSet(java.util.Set)
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment