Syntactically, a class has two basic parts:
These are coded as declarations, and belong just after the opening curly brace that comes right after the public class line.
Basic Syntax
The basic syntax for a Java class is:
public class ClassName extends ParentClass
{
// declaration of instance variable(s)
private Class instanceVariable;
...
public returnType methodName(class arg1, ...)
{
statement;
...
return x; // where x is of type returnType
}
}
The code for the class should be in a file called ClassName.java.
More notes:
Exception to using dot-notation: