Defining a Class
A class declaration consists of:
- a header giving the class name, modifiers, and possible superclass and interface structure.
and a class body usually containing:
- declarations of fields (possibly with initializations)—class variables and instance variables.
- declarations of methods.
- declarations of constructors. These “functions” look like methods, but have the same name as the class. They do initialization when objects—class instances—are created.
- nested class and interface definitions.
- class or (rarely) instance initialization statements.