Java Reference
In-Depth Information
Every type is represented by a number of different names. The actual
class or interface name is the simple name of the type. This is the
shortest name you could write in your program to represent a given
type. For example, the simple name of java.lang.Object is Object , the
simple name of the nested EnTRy interface in the java.util.Map interface
is EnTRy , the simple name of the type representing an array of Object in-
stances is Object[] , and the simple name of an array of int is int[] . All
types except for anonymous inner classes have simple names. You can
get the simple name of a type from the Class method getSimpleName .
The canonical name of a type is its full name, as you would write it
in your programs, including, if applicable, the package and enclosing
type in which the type was declared. For example, the canonical name
of Object is java.lang.Object ; for the nested EnTRy interface it is
java.util.Map.Entry ; for an array of Object instances it is
java.lang.Object[] ; and for an array of int is int[] . In more specific
terms, the canonical name of a top-level class or interface is its package
name followed by dot, followed by its simple name. The canonical name
of a nested type is the canonical name of the type in which it is declared,
followed by dot, followed by its simple name. The canonical name of
an array type is the canonical name of its element type followed by [] .
Local inner classes and anonymous inner classes do not have canonical
names. You can get the canonical name of a type from the Class method
getCanonicalName .
The canonical name is an example of a fully qualified name the simple
name qualified by the package and enclosing type, if applicable. While
simple names might be ambiguous in a given context, a fully qualified
name uniquely determines a type. Each type has only one canonical
name, but nested types (and so arrays of nested types) can have mul-
tiple fully qualified names. For example, the java.util.SortedMap inter-
face extends java.util.Map and inherits the nested Entry interface. Con-
sequently, you can identify the Entry type by the fully qualified name
java.util.SortedMap.Entry .
The binary name of a class or interface (not array) is a name used
to communicate with the virtual machine, such as by passing it to
Class.forName to ask the virtual machine for a specific Class object. The
 
Search WWH ::




Custom Search