Java Reference
In-Depth Information
}
}
This example declares a
Fibonacci
class that, like
HelloWorld
, has a
main
method. The first two lines of
main
are statements declaring two
local
variables:
lo
and
hi
. In this program
hi
is the current term in the series
and
lo
is the previous term. Local variables are declared within a block
of code, such as a method body, in contrast to fields that are declared as
members of a class. Every variable must have a
type
that precedes its
name when the variable is declared. The variables
lo
and
hi
are of type
int
, 32-bit signed integers with values in the range 2
31
through 2
31
1.
The Java programming language has built-in "primitive" data types to
support integer, floating-point, boolean, and character values. These
primitive types hold numeric data that is understood directly, as op-
posed to object types defined by programmers. The type of every vari-
able must be defined explicitly. The primitive data types are:
boolean
either
TRue
or
false
16-bit Unicode
UTF
-16 character (unsigned)
char
8-bit integer (signed)
byte
16-bit integer (signed)
short
32-bit integer (signed)
int
64-bit integer (signed)
long