Java Reference
In-Depth Information
4.3. Reference Types and Values
There are four kinds of
reference types
: class types (§8), interface types (§9), type variables
ReferenceType:
ClassOrInterfaceType
TypeVariable
ArrayType
ClassOrInterfaceType:
ClassType
InterfaceType
ClassType:
TypeDeclSpecifier TypeArguments
opt
InterfaceType:
TypeDeclSpecifier TypeArguments
opt
TypeDeclSpecifier:
TypeName
ClassOrInterfaceType
.
Identifier
TypeName:
Identifier
TypeName
.
Identifier
TypeVariable:
Identifier
ArrayType:
Type
[ ]
The sample code:
class Point { int[] metrics; }
interface Move { void move(int deltax, int deltay); }
declares a class type
Point
, an interface type
Move
, and uses an array type
int[]
(an array
of
int
) to declare the field
metrics
of the class
Point
.
A class or interface type consists of a
type declaration specifier
, optionally followed by