6.7 Fully Qualified Names

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.
  • The fully qualified name of a class or interface that is declared in an unnamed package is the simple name of the class or interface.
  • The fully qualified name of a class or 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.
  • The fully qualified name of an array type consists of the fully qualified name of the component type of the array type followed by "[]".

Examples:

  • The fully qualified name of the type long is "long".
  • The fully qualified name of the standard package java.lang is "java.lang" because it is subpackage lang of package java.
  • The fully qualified name of the class Object, which is defined in the package java.lang, is "java.lang.Object".
  • The fully qualified name of the interface Enumeration, which is defined in the package java.util, is "java.util.Enumeration".
  • The fully qualified name of the type "array of double" is "double[]".
  • The fully qualified name of the type "array of array of array of array of String" is "java.lang.String[][][][]".

In the example:

package points;

class Point { int x, y; }

class PointVec {
    Point[] vec;
}

the fully qualified name of the type Point is "points.Point"; the fully qualified name of the type PointVec is "points.PointVec"; and the fully qualified name of the type of the field vec of class PointVec is "points.Point[]".