The java.util package defines a number of useful classes, primarily collections classes that are useful for working with groups of objects. This package should not be considered merely a utility package that is separate from the rest of the language; it is an integral and frequently used part of the Java platform. The most important classes in java.util are the collections classes. Prior to Java 1.2, these were Vector , a growable list of objects, and Hashtable , a mapping between arbitrary key and value objects. Java 1.2 adds an entire collections framework consisting of the Collection , Map , Set , List , SortedMap , and SortedSet interfaces and the classes that implement them. Other important classes and interfaces of the collections framework are Comparator , Collections , Arrays , Iterator , and ListIterator . Java 1.4 extends the Collections framework with the addition of new Map and Set implementations , and a new RandomAccess marker interface used by List implementations. Java 5.0 adds a Queue collection interface and implementations. It also adds EnumSet and EnumMap which efficiently implement the Set and Map interfaces for use with enumerated types. Most importantly, Java 5.0 modifies all collection interfaces and classes to be generic types, which enable type-safe collections such as List<String> . BitSet is a related class that is not actually part of the Collections framework (and is not even a set). It provides a very compact representation of an arbitrary- size array or list of boolean values or bits. Its API was substantially enhanced in Java 1.4. The other classes of the package are also quite useful. Date , Calendar , and TimeZone work with dates and times. Currency represents a national currency. Locale represents the language and related text formatting conventions of a country, region, or culture. ResourceBundle and its subclasses represent a bundle of localized resources that are read in by an internationalized program at runtime. Random generates and returns pseudorandom numbers in a variety of forms. StringTokenizer is a simple parser that breaks a string into tokens. In Java 1.3 and later, Timer and TimerTask provide a powerful API for scheduling code to be run by a background thread, once or repetitively, at a specified time in the future. In Java 5.0, the Formatter class enables poweful formatted text output in the style of the C programming language's printf( ) function. The Java 5.0 Scanner class is a text tokenizer or scanner that can also parse numbers and match tokens based on regular expressions. Interfacespublic interface Collection <E> extends Iterable<E>; public interface Comparator <T>; public interface Enumeration <E>; public interface EventListener ; public interface Formattable ; public interface Iterator <E>; public interface List <E> extends Collection<E>; public interface ListIterator <E> extends Iterator<E>; public interface Map <K, V>; public interface Map.Entry <K, V>; public interface Observer ; public interface Queue <E> extends Collection<E>; public interface RandomAccess ; public interface Set <E> extends Collection<E>; public interface SortedMap <K, V> extends Map<K, V>; public interface SortedSet <E> extends Set<E>; Enumerated Types public enum Formatter.BigDecimalLayoutForm ; Collectionspublic abstract class AbstractCollection <E> implements Collection<E>; public abstract class AbstractList <E> extends AbstractCollection<E> implements List<E>; public abstract class AbstractSequentialList <E> extends AbstractList<E>; public class LinkedList <E> extends AbstractSequentialList<E> implements List<E>, Queue<E>, Cloneable, Serializable; public class ArrayList <E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable; public class Vector <E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable; public class Stack <E> extends Vector<E>; public abstract class AbstractQueue <E> extends AbstractCollection<E> implements Queue<E>; public class PriorityQueue <E> extends AbstractQueue<E> implements Serializable; public abstract class AbstractSet <E> extends AbstractCollection<E> implements Set<E>; public abstract class EnumSet <E extends Enum<E>> extends AbstractSet<E> implements Cloneable, Serializable; public class HashSet <E> extends AbstractSet<E> implements Set<E>, Cloneable, Serializable; public class LinkedHashSet <E> extends HashSet<E> implements Set<E>, Cloneable, Serializable; public class TreeSet <E> extends AbstractSet<E> implements SortedSet<E>, Cloneable, Serializable; public abstract class AbstractMap <K, V> implements Map<K, V>; public class EnumMap <K extends Enum<K>, V> extends AbstractMap<K, V> implements Serializable, Cloneable; public class HashMap <K, V> extends AbstractMap<K, V> implements Map<K, V>, Cloneable, Serializable; public class LinkedHashMap <K, V> extends HashMap<K, V> implements Map<K, V>; public class IdentityHashMap <K, V> extends AbstractMap<K, V> implements Map<K, V>, Serializable, Cloneable; public class TreeMap <K, V> extends AbstractMap<K, V> implements SortedMap<K, V>, Cloneable, Serializable; public class WeakHashMap <K, V> extends AbstractMap<K, V> implements Map<K, V>; public class Hashtable <K, V> extends Dictionary<K, V> implements Map<K, V>, Cloneable, Serializable; public class Properties extends Hashtable<Object, Object>; Events public class EventObject implements Serializable; Other Classespublic class Arrays ; public class BitSet implements Cloneable, Serializable; public abstract class Calendar implements Serializable, Cloneable, Comparable<Calendar>; public class GregorianCalendar extends Calendar; public class Collections ; public final class Currency implements Serializable; public class Date implements Serializable, Cloneable, Comparable<Date>; public abstract class Dictionary <K, V>; public abstract class EventListenerProxy implements EventListener; public class FormattableFlags ; public final class Formatter implements java.io.Closeable, java.io.Flushable; public final class Locale implements Cloneable, Serializable; public class Observable ; public final class PropertyPermission extends java.security.BasicPermission; public class Random implements Serializable; public abstract class ResourceBundle ; public abstract class ListResourceBundle extends ResourceBundle; public class PropertyResourceBundle extends ResourceBundle; public final class Scanner implements Iterator<String>; public class StringTokenizer implements Enumeration<Object>; public class Timer ; public abstract class TimerTask implements Runnable; public abstract class TimeZone implements Cloneable, Serializable; public class SimpleTimeZone extends TimeZone; public final class UUID implements Serializable, Comparable<UUID>; Exceptionspublic class ConcurrentModificationException extends RuntimeException; public class EmptyStackException extends RuntimeException; public class FormatterClosedException extends IllegalStateException; public class IllegalFormatException extends IllegalArgumentException; public class DuplicateFormatFlagsException extends IllegalFormatException; public class FormatFlagsConversionMismatchException extends IllegalFormatException; public class IllegalFormatCodePointException extends IllegalFormatException; public class IllegalFormatConversionException extends IllegalFormatException; public class IllegalFormatFlagsException extends IllegalFormatException; public class IllegalFormatPrecisionException extends IllegalFormatException; public class IllegalFormatWidthException extends IllegalFormatException; public class MissingFormatArgumentException extends IllegalFormatException; public class MissingFormatWidthException extends IllegalFormatException; public class UnknownFormatConversionException extends IllegalFormatException; public class UnknownFormatFlagsException extends IllegalFormatException; public class InvalidPropertiesFormatException extends java.io.IOException; public class MissingResourceException extends RuntimeException; public class NoSuchElementException extends RuntimeException; public class InputMismatchException extends NoSuchElementException; public class TooManyListenersException extends Exception; |