Book description
Java Generics and Collections has been the go-to guide to generics for more than a decade. This second edition covers Java 21, providing a clear guide to generics from their most common uses to the strangest corner cases, giving you everything you need to know to use and write generic APIs effectively. It covers the collections library thoroughly, so you'll always know how and when to use each collection for any given task. And it explains stream processing, so you'll know which model to use and how they interoperate to get the best out of the platform library.
This indispensable guide covers:
- Fundamentals of generics: type parameters and generic methods
- Subtyping and wildcards
- Generics and reflection
- Design patterns for generics
- Sets, queues, lists, maps, and their implementations
- Concurrent programming and thread safety with collections
- Performance of different collection implementations
- Best practices for using and extending the Java collections framework
- Design philosophy and comparison with other collections libraries
Publisher resources
Table of contents
- Brief Table of Contents (Not Yet Final)
- 1. Subtyping and Wildcards
- 2. Comparison and Bounds
- 3. Declarations
-
4. Effective Generics
- Use Checked Collections to Enforce Security
- Specialize to Create Reifiable Types
- Maintain Binary Compatibility
- Avoid Single-Use Type Variables
- Use Generic Helper Methods to Capture a Wildcard
- Cast Through Raw Types When Necessary
- Use Generic Array Types With Care
- Use Type Tokens for Operations Requiring Run-time Type Information
- 5. The Main Interfaces of the Java Collections Framework
- 6. Preliminaries
- 7. The Collection Interface
- 8. The SequencedCollection Interface
- 9. Sets
- 10. Queues
- 11. Lists
- 12. Maps
- 13. The Collections Class
- 14. Guidance for Using the Java Collections Framework
- 15. Design Retrospective
Product information
- Title: Java Generics and Collections, 2nd Edition
- Author(s):
- Release date: June 2025
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781098136727
You might also like
video
Understanding Java 8 Generics
Java 5 introduced generics capabilities to the language, and for most developers, simply knowing that collections …
book
Java in a Nutshell, 8th Edition
This updated edition of the Nutshell guide not only helps experienced Java programmers get the most …
book
Java Performance, 2nd Edition
Coding and testing are generally considered separate areas of expertise. In this practical book, Java expert …
book
The Well-Grounded Java Developer, Second Edition
Understanding Java from the JVM up gives you a solid foundation to grow your expertise and …