Search⌘ K

Beginning a Class Definition

Explore how to define a Java class by creating class headers, declaring data fields with proper access modifiers, and organizing class members. This lesson helps you understand the essentials of class definitions and prepares you to implement constructors and methods.

Defining the class Greeter

The definition of the class Greeter has the following form:

public class Greeter
{
   . . .
} // End Greeter

The access modifier public indicates the class’s availability. All clients may use this class. Next is the reserved word class and the name of the class. This initial portion of the ...