Java Reference
In-Depth Information
}
}
A compile-time error occurs in the method delta here: it cannot access the protected
members x and y of its parameter p , because while Point3d (the class in which the ref-
erences to fields x and y occur) is a subclass of Point (the class in which x and y are
declared), it is not involved in the implementation of a Point (the type of the parameter
p ). The method delta3d can access the protected members of its parameter q , because the
class Point3d is a subclass of Point and is involved in the implementation of a Point3d .
The method delta could try to cast (§ 5.5 , § 15.16 ) 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 protected
member z of its parameter a , because while the class Point (the class in which the ref-
erence to field z occurs) is involved in the implementation of a Point3d (the type of the
parameter a ), it is not a subclass of Point3d (the class in which z is declared).
6.7. Fully Qualified Names and Canonical Names
Every primitive type, named package, top level class, and top level interface has a fully
qualified name :
• The fully qualified name of a primitive type is the keyword for that primitive type,
namely byte , short , char , int , long , float , double , or boolean .
• 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, fol-
lowed by “ . ”, followed by the simple (member) name of the subpackage.
• The fully qualified name of a top level class or top level interface that is declared
in an unnamed package is the simple name of the class or interface.
• The fully qualified name of a top level class or top level interface that is declared
in a named package consists of the fully qualified name of the package, followed
by “ . ”, followed by the simple name of the class or interface.
Each member class, member interface, and array type may have a fully qualified name:
• A member class or member interface M of another class or interface C has a fully
qualified name if and only if C has a fully qualified name.
Search WWH ::




Custom Search