Java Generics and Collections. 2nd Edition - Helion

ISBN: 9781098136680
stron: 368, Format: ebook
Data wydania: 2025-06-17
Księgarnia: Helion
Cena książki: 186,15 zł (poprzednio: 227,01 zł)
Oszczędzasz: 18% (-40,86 zł)
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
Osoby które kupowały "Java Generics and Collections. 2nd Edition", wybierały także:
- Jak zhakowa 125,00 zł, (10,00 zł -92%)
- Windows Media Center. Domowe centrum rozrywki 66,67 zł, (8,00 zł -88%)
- Ruby on Rails. Ćwiczenia 18,75 zł, (3,00 zł -84%)
- Efekt piaskownicy. Jak szefować żeby roboty nie zabrały ci roboty 59,50 zł, (11,90 zł -80%)
- Przywództwo w świecie VUCA. Jak być skutecznym liderem w niepewnym środowisku 58,64 zł, (12,90 zł -78%)
Spis treści
Java Generics and Collections. 2nd Edition eBook -- spis treści
- Preface
- Acknowledgments for the Second Edition
- Intended Audience
- Obtaining the Example Programs
- Conventions Used in This Book
- Assertions
- OReilly Online Learning
- How to Contact Us
- Preface to the First Edition
- Acknowledgments for the First Edition
- I. Generics
- 1. Introduction
- Generic Types
- Generics Versus Templates
- Generic Methods and Varargs
- Primitive and Reference Types
- Conclusion
- Generic Types
- 2. Subtyping and Wildcards
- Subtyping and the Substitution Principle
- Wildcards
- Wildcards with extends
- Wildcards with super
- The Get and Put Principle
- Arrays
- Bounded or Unbounded?
- Using an Unbounded Wildcard
- Using a Bounded Wildcard
- Wildcard Capture
- Restrictions on Wildcards
- Instance Creation
- Generic Method Calls
- Supertypes
- Conclusion
- 3. Comparison and Bounds
- Comparable
- The Contract for Comparable
- Consistent with equals
- Comparing Integral Values
- The Maximum of a Collection
- A Fruity Example
- Comparator
- Comparator Methods
- Enumerated Types
- Multiple Bounds
- Bridge Methods
- Covariant Overriding
- Conclusion
- Comparable
- 4. Declarations
- Constructors
- Static Members
- Nested Classes
- How Erasure Works
- Conclusion
- 5. Reifiable and Nonreifiable Types
- Reifiable Types
- Instance Tests and Casts
- Unchecked Casts
- Exception Handling
- Generics and Arrays
- Generic Array Creation
- The Principle of Truth in Advertising
- How to Create Arrays
- Array Begets Array
- A Classy Alternative
- How to Define ArrayList
- The Principle of Indecent Exposure
- Array Creation and Varargs
- Where Reifiable Types Are Required
- On the Design of Java Generics
- Erasure
- Unbounded Wildcards
- Arrays
- Arrays::copyOf
- Conclusion
- 6. Reflection
- Generics for Reflection
- Reflected Types Are Reifiable Types
- Reflection for Primitive Types
- A Generic Reflection Library
- Reflection for Generics
- Reflecting Generic Types
- Conclusion
- 7. Effective Generics
- Eliminate Unchecked Warnings
- Enforce Type Safety When Calling Untrusted Code
- Specialize to Create Reifiable Types
- 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 Run-Time Type Information
- Conclusion
- II. Collections
- 8. The Main Interfaces of the Java Collections Framework
- Using the Different Collection Types
- Set
- List
- Map
- SequencedMap
- Queue
- Sequenced Collections
- SequencedCollection
- SequencedSet and NavigableSet
- Deque
- SequencedMap and NavigableMap
- Conclusion
- Using the Different Collection Types
- 9. Preliminaries
- Iterable and Iterators
- Implementations
- Views
- Performance
- Memory
- Instruction Count and the O-notation
- Immutability and Unmodifiability
- Contracts
- Content-Based Organization
- Lambdas and Streams
- Parallel Streams
- Collections and Thread Safety
- Synchronization and the Legacy Collections
- Synchronized Collections and Fail-Fast Iterators
- Concurrent Collections
- Mechanisms of concurrent collections
- Iterators
- Conclusion
- 10. The Collection Interface
- The Methods of Collection
- Adding Elements
- Removing Elements
- Querying the Contents of a Collection
- Making a Collections Contents Available for Further Processing
- Using the Methods of Collection
- Adding Elements
- Removing Elements
- Querying the Contents of a Collection
- Making a Collections Contents Available for Further Processing
- Implementing Collection
- Collection Constructors
- Conclusion
- The Methods of Collection
- 11. The SequencedCollection Interface
- The Methods of SequencedCollection
- Adding Elements
- Inspecting Elements
- Removing Elements
- Generating a Reversed View
- Conclusion
- The Methods of SequencedCollection
- 12. Sets
- Defining a Set: Equivalence Relations
- Set Implementations
- HashSet
- HashSet constructors
- CopyOnWriteArraySet
- EnumSet
- UnmodifiableSet
- Set Views of Maps
- HashSet
- SequencedSet
- LinkedHashSet
- NavigableSet
- The Methods of NavigableSet
- Retrieving the comparator
- Inspecting the first and last elements
- Removing the first and last elements
- Getting range views
- Getting closest matches
- Navigating the set in reverse order
- NavigableSet now extends SequencedSet
- TreeSet
- ConcurrentSkipListSet
- The Methods of NavigableSet
- Comparing Set Implementations
- Conclusion
- 13. Queues
- Queue Interface Methods
- Adding an Element to a Queue
- Retrieving an Element from a Queue
- Using the Methods of Queue
- Queue Implementations
- PriorityQueue
- ConcurrentLinkedQueue
- BlockingQueue
- The Methods of BlockingQueue
- Adding an element
- Removing an element
- Retrieving or querying the contents of the queue
- Using the Methods of BlockingQueue
- BlockingQueue Implementations
- LinkedBlockingQueue
- ArrayBlockingQueue
- PriorityBlockingQueue
- DelayQueue
- SynchronousQueue
- TransferQueue
- The Methods of BlockingQueue
- Deque
- The Methods of Deque
- Collection-like methods
- Queue-like methods
- Methods inherited from SequencedCollection
- Deque Implementations
- ArrayDeque
- LinkedList
- BlockingDeque
- Implementing BlockingDeque
- The Methods of Deque
- Comparing Queue Implementations
- Conclusion
- Queue Interface Methods
- 14. Lists
- List Interface Methods
- Positional Access Methods
- Search Methods
- View-Generating Methods
- List Iteration Methods
- Methods Inherited from SequencedCollection
- Factory Methods
- Using the Methods of List
- Using Range-View and Iterator Methods
- List Implementations
- ArrayList
- LinkedList
- CopyOnWriteArrayList
- UnmodifiableList
- Comparing List Implementations
- Conclusion
- List Interface Methods
- 15. Maps
- Map Interface Methods
- Iterable-like Operations
- Collection-like Operations
- Adding or replacing associations
- Removing associations
- Querying the contents of a map
- Providing Collection Views of the Keys, Values, or Entries
- Compound Operations
- Pessimistic-style atomic operations
- Optimistic-style atomic operations
- Factory Methods
- The Interface Map.Entry
- Using the Methods of Map
- Map Implementations
- HashMap
- WeakHashMap
- IdentityHashMap
- EnumMap
- UnmodifiableMap
- SequencedMap
- The Methods of SequencedMap
- Adding or updating entries
- Inspecting entries
- Removing entries
- View-generating methods
- The Methods of SequencedMap
- LinkedHashMap
- NavigableMap
- Retrieving the Comparator
- Getting Range Views
- Getting Closest Matches
- Other Views
- TreeMap
- ConcurrentMap
- ConcurrentHashMap
- ConcurrentNavigableMap
- ConcurrentSkipListMap
- Comparing Map Implementations
- Conclusion
- Map Interface Methods
- 16. 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
- Conclusion
- Generic Algorithms
- 17. Guidance for Using the Java Collections Framework
- Avoid Anemic Domain Models
- Respect the Ownership of Collections
- Prefer Immutable Objects as Set Elements or Map Keys
- Balance Client and Library Interests in API Design
- Exploit the Features of Records
- Prefer Records to Parallel Lists
- Use Records as Composite Keys
- Manage the Mutability of Records
- Avoid Legacy Implementations
- Avoid Synchronized Wrapper Collections
- Using synchronized collections safely
- Avoid LinkedList
- Avoid Synchronized Wrapper Collections
- Customize Collections Using the Abstract Classes
- Conclusion
- 18. Design Retrospective
- Fundamental Issues in the Collections Framework Design
- Desirable Characteristics of a Collections Framework
- Unmodifiability via Subtyping
- Limitations of Subtyping
- Complementing Static Typing
- Lumping and Splitting
- Summary
- nulls
- Inconsistent with equals
- Object Versus E
- Concurrent Modification
- Fundamental Issues in the Collections Framework Design
- Afterword
- Bibliography
- Index