Java Reference
In-Depth Information
16.1 Introduction
16.2 Collections Overview
16.3 Type-Wrapper Classes
16.4 Autoboxing and Auto-Unboxing
16.5 Interface Collection and Class
Collections
16.6 Lists
16.6.1 ArrayList and Iterator
16.6.2 LinkedList
16.7 Collections Methods
16.7.1 Method sort
16.7.2 Method shuffle
16.7.3 Methods reverse , fill , copy , max
and min
16.7.4 Method binarySearch
16.7.5 Methods addAll , frequency and
disjoint
16.8 Stack Class of Package java.util
16.9 Class PriorityQueue and Interface
Queue
16.10 Sets
16.11 Maps
16.12 Properties Class
16.13 Synchronized Collections
16.14 Unmodifiable Collections
16.15 Abstract Implementations
16.16 Wrap-Up
Summary | Self-Review Exercises | Answers to Self-Review Exercises | Exercises
16.1 Introduction
In Section 7.16, we introduced the generic ArrayList collection—a dynamically resizable
array-like data structure that stores references to objects of a type that you specify when
you create the ArrayList . In this chapter, we continue our discussion of the Java collec-
tions framework , which contains many other prebuilt generic data-structures.
Some examples of collections are your favorite songs stored on your smartphone or
media player, your contacts list, the cards you hold in a card game, the members of your
favorite sports team and the courses you take at once in school.
We discuss the collections-framework interfaces that declare the capabilities of each
collection type, various classes that implement these interfaces, methods that process col-
lection objects, and iterators that “walk through” collections.
Java SE 8
After reading Chapter 17, Java SE 8 Lambdas and Streams, you'll be able to reimplement
many of Chapter 16's examples in a more concise and elegant manner, and in a way that
makes them easier to parallelize to improve performance on today's multi-core systems. In
Chapter 23, Concurrency, you'll learn how to improve performance on multi-core sys-
tems using Java's concurrent collections and parallel stream operations.
16.2 Collections Overview
A collection is a data structure—actually, an object—that can hold references to other ob-
jects. Usually, collections contain references to objects of any type that has the is-a rela-
tionship with the type stored in the collection. The collections-framework interfaces
declare the operations to be performed generically on various types of collections.
Figure 16.1 lists some of the collections framework interfaces. Several implementations of
these interfaces are provided within the framework. You may also provide your own im-
plementations.
 
 
 
Search WWH ::




Custom Search