Java Reference
In-Depth Information
then class Point4d would inherit the field z , which, being public , could then be accessed
by code in packages other than morePoints , through variables and expressions of the
public type Point4d .
8.3. Field Declarations
The variables of a class type are introduced by field declarations .
FieldDeclaration:
FieldModifiers opt Type VariableDeclarators ;
VariableDeclarators:
VariableDeclarator
VariableDeclarators , VariableDeclarator
VariableDeclarator:
VariableDeclaratorId
VariableDeclaratorId = VariableInitializer
VariableDeclaratorId:
Identifier
VariableDeclaratorId [ ]
VariableInitializer:
Expression
ArrayInitializer
The FieldModifiers are described in § 8.3.1 .
The Identifier in a FieldDeclarator may be used in a name to refer to the field.
More than one field may be declared in a single field declaration by using more than one
declarator; the FieldModifiers and Type apply to all the declarators in the declaration.
The declared type of a field is denoted by the Type that appears in the field declaration,
followed by any bracket pairs that follow the Identifier in the declarator.
It is a compile-time error for the body of a class declaration to declare two fields with the
same name.
The scope and shadowing of a field declaration is specified in § 6.3 and § 6.4 .
If the class declares a field with a certain name, then the declaration of that field is said to
hide any and all accessible declarations of fields with the same name in superclasses, and
superinterfaces of the class.
Search WWH ::




Custom Search