Java Reference
In-Depth Information
ing class. Member classes may be
static
, in which case they have no access to the instance
Member interface declarations (§
8.5
) describe nested interfaces that are members of the
surrounding class.
pressions (§
15.12
). A class method is invoked relative to the class type; an instance method
is invoked with respect to some particular object that is an instance of a class type. A meth-
od whose declaration does not indicate how it is implemented must be declared
abstract
. A
method (§
8.4.3.6
) automatically locks an object before executing its body and automatic-
lowing its activities to be synchronized with those of other threads (§17).
Instance initializers (§
8.6
) are blocks of executable code that may be used to help initialize
Static initializers (§
8.7
) are blocks of executable code that may be used to help initialize a
class.
Constructors (§
8.8
) are similar to methods, but cannot be invoked directly by a method
call; they are used to initialize new class instances. Like methods, they may be overloaded
8.1. Class Declarations
A class declaration specifies a new named reference type.
There are two kinds of class declarations:
normal class declarations
and
enum declara-
tions
.
ClassDeclaration:
NormalClassDeclaration
EnumDeclaration
NormalClassDeclaration:
ClassModifiers
opt
class
Identifier TypeParameters
opt
Super
opt
Interfaces
opt
ClassBody