Java Reference
In-Depth Information
BlockStatements BlockStatement
BlockStatement:
LocalVariableDeclarationStatement
ClassDeclaration
Statement
A block is executed by executing each of the local variable declaration statements and other
statements in order from first to last (left to right). If all of these block statements complete
normally, then the block completes normally. If any of these block statements complete ab-
ruptly for any reason, then the block completes abruptly for the same reason.
14.3. Local Class Declarations
A local class is a nested class (§8) that is not a member of any class and that has a name
6.2 , § 6.7 ) .
All local classes are inner classes (§ 8.1.3 ).
Every local class declaration statement is immediately contained by a block (§ 14.2 ). Local
class declaration statements may be intermixed freely with other kinds of statements in the
block.
It is a compile-time error if a local class declaration contains any of the access modifiers
public , protected , or private 6.6 ) , or the modifier static 8.1.1 ) .
The scope and shadowing of a local class declaration is specified in § 6.3 and § 6.4 .
Example 14.3-1. Local Class Declarations
Here is an example that illustrates several aspects of the rules given above:
Click here to view code image
class Global {
class Cyclic {}
void foo() {
new Cyclic(); // create a Global.Cyclic
class Cyclic extends Cyclic {} // circular definition
{
class Local {}
{
class Local {} // compile-time error
}
class Local {} // compile-time error
Search WWH ::




Custom Search