Types: Primitive Types & Classes
- A class defines a new type.
We can have many values of that type, called objects or
instances of the class.
- The operations on a class type are its methods or
To find out what methods are available for a class, look at its
The syntax for calling or invoking a method is:
Methods always include parentheses. If the
method needs the user to pass some information to it, that
information goes inside the parentheses.
- Classes have special methods called constructors.
The name of a constructor is always the same as the name of the class.
You construct an object with the
new keyword and the
Fish fish1 = new Fish();
- Naming convention: class names
start with upper-case letters, while object variable names and
method names start with lower-case letters.
Alyce Brady, Kalamazoo College