Java Reference
In-Depth Information
Member class declarations (§ 8.5 ) describe nested classes that are members of the surround-
ing class. Member classes may be static , in which case they have no access to the instance
variables of the surrounding class; or they may be inner classes (§ 8.1.3 ) .
Member interface declarations (§ 8.5 ) describe nested interfaces that are members of the
surrounding class.
Method declarations (§ 8.4 ) describe code that may be invoked by method invocation ex-
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 may be declared final 8.4.3.3 ) , in which case it cannot be hidden or overridden.
A method may be implemented by platform-dependent native code (§ 8.4.3.4 ). A synchronized
method (§ 8.4.3.6 ) automatically locks an object before executing its body and automatic-
ally unlocks the object on return, as if by use of a synchronized statement (§ 14.19 ), thus al-
lowing its activities to be synchronized with those of other threads (§17).
Method names may be overloaded (§ 8.4.9 ) .
Instance initializers (§ 8.6 ) are blocks of executable code that may be used to help initialize
an instance when it is created (§ 15.9 ) .
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.8.8 ) .
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
Search WWH ::




Custom Search