CLASSES
Field Declarations
8.3
type
Point3d
 cannot be referred to outside package
morePoints
. The declaration
of the field
z
 as
public
 is not useless, however. If there were to be, in package
morePoints
, a
public
 subclass
Point4d
 of the class
Point3d
:
package morePoints;
public class Point4d extends Point3d {
public int w;
public void move(int dx, int dy, int dz, int dw) {
super.move(dx, dy, dz); w += dw;
}
}
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
Poetic fields encompass me around,
And still I seem to tread on classic ground.
 Joseph Addison (1672 1719),
A Letter from Italy
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. The name of a field has as its scope
143






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved