Defining a Class
Purpose:
- To create a template from which object instances are made.
Mechanics:
<modifiers> class <class name> {/* Instance variables declared and methods defined here */
}
Example:
public class myClass {/* instance variables *//* methods */
}
Usage:
- <modifiers> is an optional space-separated list of valid class modifiers.
- <class name> must be a valid identifier unique to the package.
- The instance variables declared and methods defined within the brackets give the object its behavior and the basis for its state.
Restrictions:
- A class definition normally contains one or more constructors. If a constructor is not defined, the Java compiler will supply a default constructor automatically. s
email suggestions to: cs015tas@cs.brown.edu
