Java Reference
In-Depth Information
the password class keeps an active history of four passwords by default, while the
expiresNotifyLimit variable is set to 3 so that users are notified of an expiring pass-
word when the number of remaining uses is 3 or less. As shown in lines 13 and 14,
you should make final variables static whenever possible. This reduces the required
memory, as static variables are shared across all instances.
Making Final Variables Static
Making final variables static ensures that the same value is used
for all instances. Also, if you forget to initialize such a variable, the
compiler will generate an error message to remind you.
Understanding the Collections Framework
A data structure is simply a format for storing a group, or collection , of data.
The format may indicate, whether implicitly or explicitly, how the data is to be
accessed or otherwise manipulated. For example, as you learned in Chapter 5,
an array is a type of general data structure that utilizes an index to access data
stored in the array.
Java provides an application program interface (API) for dealing with a num-
ber of common data structures, or collections, called the Collections Framework .
The Collections Framework provides interfaces, implementations, and algorithms
for representing and manipulating collections. Among other uses, interfaces are
used to provide a general means for manipulating collections independent of how
the collections are represented (for example, as lists, maps, or sets); interfaces will
be discussed in detail in a later chapter. The implementations provide essentially
reusable data structures from the collections interfaces, such as ArrayList , which
is a list implemented as an array. A list is simply an ordered collection, such as a
list of names. The algorithms provide a means of performing operations — such
as adding to or retrieving from the list, searching, and sorting — on objects that
implement the Collections Framework interfaces. Figure 9-8 represents the hier-
archy of interfaces in the Collections Framework. The Collections Framework is
based on the collections listed in Table 9-4 on the next page.
Collections Framework
Hierarchy
Collection
Map
Set
List
Sorted Map
Sorted Set
FIGURE 9-8
Search WWH ::




Custom Search