NAMES
Fully Qualified Names
6.7
The method
delta
could try to cast ( 5.4, 15.15) its parameter to be a
Point3d
, but this cast would fail, causing an exception, if the class of
p
at run
time were not
Point3d
.
A compile time error also occurs in the method warp: it cannot access the pro
tected member
z
of its parameter
a
, because while the class
Point
(the class in
which the reference to field
z
occurs) is involved in the implementation of a
Point
(the type of the parameter a), it is not a subclass of
Point
(the class in
which
z
is declared).
6.6.8 Example:
private
Fields, Methods, and Constructors
A private
class member or constructor is accessible only within the class body in
which the member is declared and is not inherited by subclasses. In the example:
class Point {
Point() { setMasterID(); }
int x, y;
private int ID;
private static int masterID = 0;
private void setMasterID() { ID = masterID++; }
}
the
private
members
ID,
m
asterID
, and
setMasterID
may be used only
within the body of class
Point
. They may not be accessed by qualified names,
field access expressions, or method invocation expressions outside the body of the
declaration of
Point
.
See 8.6.8 for an example that uses a
private
constructor.
6.7 Fully Qualified Names
Every package, class, interface, array type, and primitive type has a fully qualified
name. It follows that every type except the null type has a fully qualified name.
The fully qualified name of a primitive type is the keyword for that primitive
type, namely
boolean
,
char
,
byte
,
short
,
int
,
long
,
float
, or
double
.
The fully qualified name of a named package that is not a subpackage of a
named package is its simple name.
The fully qualified name of a named package that is a subpackage of another
named package consists of the fully qualified name of the containing package,
followed by
.
, followed by the simple (member) name of the subpackage.
105
footer
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