CHAPTER 4: Types, Values, and Variables Previous
Previous
Java Language
Java Language
Index
Index
Next
Next

4.1 Primitive Types, Reference Types, and the Null Type

There are two kinds of types in Java: primitive types (S4.2) and reference types (S4.3). There are, correspondingly, two kinds of data values that can be stored in variables, passed as arguments, returned by methods, and operated on: primitive values (S4.2) and reference values (S4.3).


Type:

	PrimitiveType

	ReferenceType

There is also a special null type, the type of the expression null , which has no name. Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type. The null reference is the only possible value of an expression of null type. The null reference can always be cast to any reference type. In practice, the Java programmer can ignore the null type and just pretend that null is merely a special literal that can be of any reference type.

© 1996 Sun Microsystems, Inc. All rights reserved.