Java Reference
In-Depth Information
8.5.1. Static Member Type Declarations
The static keyword may modify the declaration of a member type C within the body of a
non-inner class or interface T . Its effect is to declare that C is not an inner class. Just as a
static method of T has no current instance of T in its body, C also has no current instance of
T , nor does it have any lexically enclosing instances.
It is a compile-time error if a static class contains a usage of a non- static member of an en-
closing class.
A member interface is implicitly static 9.1.1 ). It is permitted for the declaration of a mem-
ber interface to redundantly specify the static modifier.
8.6. Instance Initializers
An instance initializer declared in a class is executed when an instance of the class is cre-
ated (§ 12.5 , § 15.9 , § 8.8.7.1 ) .
InstanceInitializer:
Block
It is a compile-time error if an instance initializer cannot complete normally (§ 14.21 ) .
It is a compile-time error if a return statement (§ 14.17 ) appears anywhere within an instance
initializer.
Instance initializers are permitted to refer to the current object via the keyword this
15.8.3 ) , to use the keyword super 15.11.2 , § 15.12 ), and to use any type variables in
scope.
Use of instance variables whose declarations appear textually after the use is some-
times restricted, even though these instance variables are in scope. See § 8.3.2.3 for
the precise rules governing forward reference to instance variables.
Exception checking for an instance initializer is specified in § 11.2.3 .
8.7. Static Initializers
A static initializer declared in a class is executed when the class is initialized (§ 12.4.2 ). To-
gether with any field initializers for class variables (§ 8.3.2 ) , static initializers may be used
to initialize the class variables of the class.
StaticInitializer:
Search WWH ::




Custom Search