|
The core language packages provide a number of classes that provide
tools that you find very handy in your programs. Many, but not all,
of these come in the appropriately named java.util
package. In ths chapter we survey a selection of these useful tools:
- Vector
& Enumeration - - unlike an array, Vector
objects contain a list of objects that can grow or shrink. The
Enumeration
cycles once through each item in a list such as a Vector.
- Hashtable,
HashMap and Properties - associative arrays of objects
that use key/value pairs
- Collections Framework - other
classes and interfaces dealing with collections of objects.
- Iterator
& ArrayList - Iterator offers an improved tool
over Enumeration
for cycling through each item in a list such as an a ArrayList.
The latter class is similar to Vector
but faster due to no synchronization.
- Generics - new capability added
in J2SE5.0 in which the collections classes can be restricted
at compile-time to a particular class type rather than only Object.
- Preferences API - the java.util.prefs
package contains a set of classes that supports a program's user
preference record-keeping.
- Concurrency Utilities in J2SE5.0
- enhanced tools added with J2SE5.0 for dealing efficiently with
threads.
- Enumerated Types in J2SE5.0
- new capability in J2SE5.0 for defiining a special enum
type that only takes the values of a specified set of constants.
- Arrays
Class - lots of methods for dealing with arrays such as searching
and sorting.
- String tools: - discussion
of various tools for manipulating strings
- Date,
Calendar and Time - methods for date/time handling
- Other Utilities - other utilities
including more classes and sub-packages of java.util.
- Exercises
See also
Other java.util
packages and sub-packages not discussed in this chapter are listed
in the Other Utilities section.
Latest update Nov. 16, 2004
|
|
|