Java Reference
In-Depth Information
Chapter 4. Types, Values, and Variables
The Java programming language is a
statically typed
language, which means that every vari-
able and every expression has a type that is known at compile time.
The Java programming language is also a
strongly typed
language, because types limit the
tions supported on those values, and determine the meaning of the operations. Strong static
typing helps detect errors at compile time.
The types of the Java programming language are divided into two categories: primitive types
The numeric types are the integral types
byte
,
short
,
int
,
long
, and
char
, and the floating-point
types. There is also a special null type. An object (§
4.3.1
) is a dynamically created instance
of a class type or a dynamically created array. The values of a reference type are references
4.1. The Kinds of Types and Values
reference types (§
4.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
Type:
PrimitiveType
ReferenceType
There is also a special
null type
, the type of the expression
null
(§
3.10.7
, §
15.8.1
), 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 undergo a widening reference conversion to any reference
type.