Immutable Empty Collections
suggest changeSometimes it is appropriate to use an immutable empty collection. The Collections class provides methods to get such collections in an efficient way:
List<String> anEmptyList = Collections.emptyList();
Map<Integer, Date> anEmptyMap = Collections.emptyMap();
Set<Number> anEmptySet = Collections.emptySet();
The methods are generic. The compiler infers the type arguments from the assignment; it does not convert the collection at runtime. emptyList() can therefore be assigned to any List type, and the same is true of emptySet() and emptyMap(). Each method returns a shared empty singleton, so a List<String> and a List<Integer> from emptyList() are the same object. The type arguments are erased.
The collections returned by these methods are immutable in that they will throw UnsupportedOperationException if you attempt to call methods which would change their contents (add, put, etc.). These collections are primarily useful as substitutes for empty method results or other default values, instead of using null or creating objects with new.