Such classes, called inner classes, should be ones that exist only to support the work of the class in which they nest. For example, the sole purpose of the SortMetrics class on page 75 is to return multiple values from the metrics method of the SortDouble class. An inner class name is qualified by its enclosing class. In this case, the proper name of SortMetrics is SortDouble. SortMetrics , and so its declaration in SimpleSortDouble on page 76 would be SortDouble.
Inner classes can also be public or package accessible.
The example above declares SortMetrics as static . An inner class that is not static has an implicit reference to its enclosing object, which is the object that created the inner class object. This reference is useful because many inner classes are strongly tied to particular objects, and need to access their fields. We use the shorter class name Enumerate because the class is already nested inside WhichChars , so EnumerateWhichChars would be redundant. In the original code on page 222, used was passed as a parameter to the class's constructor, which stored the reference in a field of its own called bits .