3.1. Class Definition SyntaxAt its simplest level, a class definition consists of the keyword class followed by the name of the class and a set of class members within curly braces. The class keyword may be preceded by modifier keywords and annotations (see Chapter 4). If the class extends another class, the class name is followed by the extends keyword and the name of the class being extended. If the class implements one or more interfaces then the class name or the extends clause is followed by the implements keyword and a comma-separated list of interface names. For example: public class Integer extends Number implements Serializable, Comparable { // class members go here } Generic class declarations include additional syntax that is covered in Chapter 4. Class declarations may include zero or more of the following modifiers:
A class cannot be both abstract and final. By convention, if a class has more than one modifier, they appear in the order shown. |