How do you create an immutable collection?

The Java Collections Framework provides a set of methods, Collections.unmodifiable*(), for various collection types. These methods return a read-only wrapper around the provided collection. Similar to Collections.synchronized*(), the wrapper uses the original collection, not a copy.

Another less obvious option is Collections.empty*(). It returns an unmodifiable empty collection. Any attempt to add an element, as with unmodifiable*, will result in an UnsupportedOperationException.