Java Reference
In-Depth Information
with respect to an instance. In the case of instance variables of an enclosing class, the
instance variable must be defined with respect to an enclosing instance of that class.
For example, the class Local above has an enclosing instance of class Outer . As a fur-
ther example:
Click here to view code image
class WithDeepNesting {
boolean toBe;
WithDeepNesting(boolean b) { toBe = b; }
class Nested {
boolean theQuestion;
class DeeplyNested {
DeeplyNested(){
theQuestion = toBe || !toBe;
}
}
}
}
Here, every instance of WithDeepNesting.Nested.DeeplyNested has an enclosing instance of
class WithDeepNesting.Nested (its immediately enclosing instance) and an enclosing in-
stance of class WithDeepNesting (its 2nd lexically enclosing instance).
8.1.4. Superclasses and Subclasses
The optional extends clause in a normal class declaration specifies the direct superclass of
the current class.
Super:
extends ClassType
The following is repeated from § 4.3 to make the presentation here clearer:
ClassType:
TypeDeclSpecifier TypeArguments opt
The extends clause must not appear in the definition of the class Object , or a compile-time
error occurs, because it is the primordial class and has no direct superclass.
The ClassType must name an accessible (§ 6.6 ) class type, or a compile-time error occurs.
If the specified ClassType names a class that is final 8.1.1.2 ) , then a compile-time error
occurs, as final classes are not allowed to have subclasses.
Search WWH ::




Custom Search