public class ClassName extends ParentClass
{
private Class instanceVariable;
...
public returnType methodName(class arg1, ...)
{
statement;
...
}
}
The code for the class should be in a file called ClassName.java.
You
may put multiple classes in a single source file, but only the main
one, the one that matches the filename, should be declared as public.
If you create a class that does not specify its superclass with the extends keyword, it
automatically is defined as a subclass of the
Object
class (this has more relevance if/when we discuss inheritance).
The instance variables are also called attributes, data members, member variables, or fields.
The section that creates these variables can only consist of declarations.
To create an object of your new class, the programmer must call a constructor. (How is this done?)
To call a method in the class, the programmer should use dot-notation. (How is this done?)
Exception to using dot-notation:
To call a method in the same class, do not use dot-notation, just call the method directly.
For now, write your classes in the same directory and there is no need to import them.