February 2014
Beginner
1248 pages
62h 25m
English
The Collections class provides a set of static methods that create unmodifiable wrappers for collections. Unmodifiable wrappers throw UnsupportedOperationExceptions if attempts are made to modify the collection. In an unmodifiable collection, the references stored in the collection are not modifiable, but the objects they refer are modifiable unless they belong to an immutable class like String. Headers for these methods are listed in Fig. 16.21. Details about these methods are available at http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html. All these methods take a generic type and return an unmodifiable view of the generic type. For example, the following code creates an unmodifiable List (
Read now
Unlock full access