We now take a deeper look at building classes, controlling access to members of a class and creating constructors. We discuss composition—a capability that allows a class to have references to objects of other classes as members. Recall that Section D.10 introduced the basic enum
type to declare a set of constants. In this appendix, we discuss the relationship between enum
types and classes, demonstrating that an enum
, like a class, can be declared in its own file with constructors, methods and fields. The appendix also discusses static
class members and final
instance variables in detail. Finally, we explain how to organize classes in packages to help manage large applications and promote reuse, then show a special relationship between classes in the same package.