go to previous page   go to home page   go to next page


Yes. A big program might need thousands of objects as it runs, but might have only a few dozen class descriptions.

Syntax of a Class Definition

Class definitions look like this:

class ClassName

  Descriptions of the instance variables and methods each object
  will have and the constructors that initialize a new object.


Often programmers separate the definition into three sections:

class ClassName
  // Description of the variables.

  // Description of the constructors.

  // Description of the methods.

Separating the class into sections is done for clarity. It is not a rule of the language. A simple class might have just a few variables and be defined in just a few lines of code. A large, complicated class might take thousands of lines of code for its definition.


Does each object require a main() method?