|
|
|
Copyright
|
|
|
|
Dedication
|
|
|
|
Preface
|
|
|
|
Part I: Generics
|
|
|
|
|
Chapter 1. Introduction
|
|
|
|
|
Section 1.1. Generics
|
|
|
|
|
Section 1.2. Boxing and Unboxing
|
|
|
|
|
Section 1.3. Foreach
|
|
|
|
|
Section 1.4. Generic Methods and Varargs
|
|
|
|
|
Section 1.5. Assertions
|
|
|
|
|
Chapter 2. Subtyping and Wildcards
|
|
|
|
|
Section 2.1. Subtyping and the Substitution Principle
|
|
|
|
|
Section 2.2. Wildcards with extends
|
|
|
|
|
Section 2.3. Wildcards with super
|
|
|
|
|
Section 2.4. The Get and Put Principle
|
|
|
|
|
Section 2.5. Arrays
|
|
|
|
|
Section 2.6. Wildcards Versus Type Parameters
|
|
|
|
|
Section 2.7. Wildcard Capture
|
|
|
|
|
Section 2.8. Restrictions on Wildcards
|
|
|
|
|
Chapter 3. Comparison and Bounds
|
|
|
|
|
Section 3.1. Comparable
|
|
|
|
|
Section 3.2. Maximum of a Collection
|
|
|
|
|
Section 3.3. A Fruity Example
|
|
|
|
|
Section 3.4. Comparator
|
|
|
|
|
Section 3.5. Enumerated Types
|
|
|
|
|
Section 3.6. Multiple Bounds
|
|
|
|
|
Section 3.7. Bridges
|
|
|
|
|
Section 3.8. Covariant Overriding
|
|
|
|
|
Chapter 4. Declarations
|
|
|
|
|
Section 4.1. Constructors
|
|
|
|
|
Section 4.2. Static Members
|
|
|
|
|
Section 4.3. Nested Classes
|
|
|
|
|
Section 4.4. How Erasure Works
|
|
|
|
|
Chapter 5. Evolution, Not Revolution
|
|
|
|
|
Section 5.1. Legacy Library with Legacy Client
|
|
|
|
|
Section 5.2. Generic Library with Generic Client
|
|
|
|
|
Section 5.3. Generic Library with Legacy Client
|
|
|
|
|
Section 5.4. Legacy Library with Generic Client
|
|
|
|
|
Section 5.5. Conclusions
|
|
|
|
|
Chapter 6. Reification
|
|
|
|
|
Section 6.1. Reifiable Types
|
|
|
|
|
Section 6.2. Instance Tests and Casts
|
|
|
|
|
Section 6.3. Exception Handling
|
|
|
|
|
Section 6.4. Array Creation
|
|
|
|
|
Section 6.5. The Principle of Truth in Advertising
|
|
|
|
|
Section 6.6. The Principle of Indecent Exposure
|
|
|
|
|
Section 6.7. How to Define ArrayList
|
|
|
|
|
Section 6.8. Array Creation and Varargs
|
|
|
|
|
Section 6.9. Arrays as a Deprecated Type?
|
|
|
|
|
Section 6.10. Summing Up
|
|
|
|
|
Chapter 7. Reflection
|
|
|
|
|
Section 7.1. Generics for Reflection
|
|
|
|
|
Section 7.2. Reflected Types are Reifiable Types
|
|
|
|
|
Section 7.3. Reflection for Primitive Types
|
|
|
|
|
Section 7.4. A Generic Reflection Library
|
|
|
|
|
Section 7.5. Reflection for Generics
|
|
|
|
|
Section 7.6. Reflecting Generic Types
|
|
|
|
|
Chapter 8. Effective Generics
|
|
|
|
|
Section 8.1. Take Care when Calling Legacy Code
|
|
|
|
|
Section 8.2. Use Checked Collections to Enforce Security
|
|
|
|
|
Section 8.3. Specialize to Create Reifiable Types
|
|
|
|
|
Section 8.4. Maintain Binary Compatibility
|
|
|
|
|
Chapter 9. Design Patterns
|
|
|
|
|
Section 9.1. Visitor
|
|
|
|
|
Section 9.2. Interpreter
|
|
|
|
|
Section 9.3. Function
|
|
|
|
|
Section 9.4. Strategy
|
|
|
|
|
Section 9.5. Subject-Observer
|
|
|
|
Part II: Collections
|
|
|
|
|
Chapter 10. The Main Interfaces of the Java Collections Framework
|
|
|
|
|
Chapter 11. Preliminaries
|
|
|
|
|
Section 11.1. Iterable and Iterators
|
|
|
|
|
Section 11.2. Implementations
|
|
|
|
|
Section 11.3. Efficiency and the O-Notation
|
|
|
|
|
Section 11.4. Contracts
|
|
|
|
|
Section 11.5. Collections and Thread Safety
|
|
|
|
|
Chapter 12. The Collection Interface
|
|
|
|
|
Section 12.1. Using the Methods of Collection
|
|
|
|
|
Section 12.2. Implementing Collection
|
|
|
|
|
Section 12.3. Collection Constructors
|
|
|
|
|
Chapter 13. Sets
|
|
|
|
|
Section 13.1. Implementing Set
|
|
|
|
|
Section 13.2. SortedSet and NavigableSet
|
|
|
|
|
Section 13.3. Comparing Set Implementations
|
|
|
|
|
Chapter 14. Queues
|
|
|
|
|
Section 14.1. Using the Methods of Queue
|
|
|
|
|
Section 14.2. Implementing Queue
|
|
|
|
|
Section 14.3. BlockingQueue
|
|
|
|
|
Section 14.4. Deque
|
|
|
|
|
Section 14.5. Comparing Queue Implementations
|
|
|
|
|
Chapter 15. Lists
|
|
|
|
|
Section 15.1. Using the Methods of List
|
|
|
|
|
Section 15.2. Implementing List
|
|
|
|
|
Section 15.3. Comparing List Implementations
|
|
|
|
|
Chapter 16. Maps
|
|
|
|
|
Section 16.1. Using the Methods of Map
|
|
|
|
|
Section 16.2. Implementing Map
|
|
|
|
|
Section 16.3. SortedMap and NavigableMap
|
|
|
|
|
Section 16.4. ConcurrentMap
|
|
|
|
|
Section 16.5. ConcurrentNavigableMap
|
|
|
|
|
Section 16.6. Comparing Map Implementations
|
|
|
|
|
Chapter 17. The Collections Class
|
|
|
|
|
Section 17.1. Generic Algorithms
|
|
|
|
|
Section 17.2. Collection Factories
|
|
|
|
|
Section 17.3. Wrappers
|
|
|
|
|
Section 17.4. Other Methods
|
|
|
|
About the Authors
|
|
|
|
Colophon
|
|
|
|
Index
|