Java is what computer scientists and programmers call a
"strongly typed language." What this means is that
all of the
expressions,
fields,
methods, and
literals in your
Java classes have specific sets of values that they
can evaluate to or contain.
type can be further broken down into
primitive types
and reference types.
There is one exception to this and that is that methods
are allowed to return nothing so there is a reserved word
meaning NO type. Methods of this type are declared
to be of type void.
There are eight primitive
types in Java:
- boolean
- values: true or false
- byte
- -128 through 127
- char
- 0 through 65535
- short
- -32768 through 32767
- int
- values: -2,147,483,648 through
2,147,483,647
- long
- -92,233,720,036,854,775,808 through
92,233,720,036,854,775,807
- float
-
- double
-
Reference types consist of
objects. Reference types have been declared somewhere
as classes. Java comes with many predefined classes,
for example: String.