Java Reference
In-Depth Information
ClassBody:
{
ClassBodyDeclarations
opt
}
ClassBodyDeclarations:
ClassBodyDeclaration
ClassBodyDeclarations ClassBodyDeclaration
ClassBodyDeclaration:
ClassMemberDeclaration
InstanceInitializer
StaticInitializer
ConstructorDeclaration
ClassMemberDeclaration:
FieldDeclaration
MethodDeclaration
ClassDeclaration
InterfaceDeclaration
;
The scope and shadowing of a declaration of a member
m
declared in or inherited by a class
If
C
itself is a nested class, there may be definitions of the same kind (variable, meth-
od, or type) and name as
m
in enclosing scopes. (The scopes may be blocks, classes,
or packages.) In all such cases, the member
m
declared in or inherited by
C
shadows
8.2. Class Members
The members of a class type are all of the following:
has no direct superclass
• Members declared in the body of the class (§
8.1.6
)
Members of a class that are declared
private
are not inherited by subclasses of that class.
Only members of a class that are declared
protected
or
public
are inherited by subclasses de-
clared in a package other than the one in which the class is declared.
Constructors, static initializers, and instance initializers are not members and therefore are
not inherited.