Java Generics and Collections, 2nd Edition (Second Early Release) [2 ed.] 9781098136727, 9781098136666

Java Generics and Collections has been the go-to guide to generics for more than a decade. This second edition covers Ja

1,096 226 4MB

English Pages 300 Year 2023

Report DMCA / Copyright

DOWNLOAD FILE

Java Generics and Collections, 2nd Edition (Second Early Release) [2 ed.]
 9781098136727, 9781098136666

Table of contents :
1. Subtyping and Wildcards
Subtyping and the Substitution Principle
Wildcards with extends
Wildcards with super
The Get and Put Principle
Arrays
Wildcards Versus Type Parameters
Wildcard Capture
Restrictions on Wildcards
2. Comparison and Bounds
Comparable
Maximum of a Collection
A Fruity Example
Comparator
Enumerated Types
Multiple Bounds
Bridges
Covariant Overriding
3. Declarations
Constructors
Static Members
Nested Classes
How Erasure Works
4. The Main Interfaces of the Java Collections Framework
Collection
Set
List
Queue
Map
Using the Different Collection Types
Sequenced Collections
SequencedCollection
SequencedSet and NavigableSet
Deque
SequencedMap and NavigableMap
5. Preliminaries
Iterable and Iterators
Implementations
Views
Performance
Memory
Instruction Count and the O-notation
Immutability and Unmodifiability
Contracts
Content-based Organization
Lambdas and Streams
Collections and Thread Safety
Synchronization and the Legacy Collections
Java 2: Synchronized Collections and Fail-Fast Iterators
Java 5: Concurrent Collections
6. The Collection Interface
Using the Methods of Collection
Implementing Collection
Collection Constructors
7. The SequencedCollection Interface
8. Sets
Set Implementations
HashSet
CopyOnWriteArraySet
EnumSet
UnmodifiableSet
SequencedSet
LinkedHashSet
NavigableSet
TreeSet
ConcurrentSkipListSet
Comparing Set Implementations
9. Queues
Using the Methods of Queue
Queue Implementations
PriorityQueue
ConcurrentLinkedQueue
BlockingQueue
Using the Methods of BlockingQueue
BlockingQueue Implementations
LinkedBlockingQueue
ArrayBlockingQueue
PriorityBlockingQueue
DelayQueue
SynchronousQueue
TransferQueue
Deques
Deque Implementations
ArrayDeque
LinkedList
BlockingDeque
Implementing BlockingDeque
Comparing Queue Implementations
10. Lists
Using the Methods of List
List Implementations
ArrayList
LinkedList
CopyOnWriteArrayList
Comparing List Implementations
11. Maps
Map.Entry
Using the Methods of Map
Map Implementations
HashMap
WeakHashMap
IdentityHashMap
EnumMap
UnmodifiableMap
SequencedMap
LinkedHashMap
NavigableMap
TreeMap
ConcurrentMap
ConcurrentHashMap
ConcurrentNavigableMap
ConcurrentSkipListMap
Comparing Map Implementations
12. The Collections Class
Generic Algorithms
Changing the Order of List Elements
Changing the Contents of a List
Finding Extreme Values in a Collection
Finding Specific Values in a List
Collection Factories
Wrappers
Synchronized Collections
Unmodifiable Collections
Checked Collections
Other Methods

Polecaj historie