Java Reference
In-Depth Information
Punctuation
Java also uses a number of punctuation characters as tokens. The Java Language
Specification divides these characters (somewhat arbitrarily) into two categories,
separators and operators. The twelve separators are:
(
)
{
}
[
]
...
@
::
;
,
.
The operators are:
+
—
*
/
%
&
|
^
<<
>>
>>>
+=
-=
*=
/=
%=
&=
|=
^=
<<=
>>=
>>>=
=
==
!=
<
<=
>
>=
!
~
&&
||
++
--
?
:
->
We'll see separators throughout the topic, and will cover each operator individually
in
“Expressions and Operators” on page 30
.
Primitive Data Types
Java supports eight basic data types known as
primitive types
as described in
Table
2-1
. The primitive types include a Boolean type, a character type, four integer types,
and two floating-point types. The four integer types and the two floating-point types
differ in the number of bits that represent them and therefore in the range of num‐
bers they can represent.
Table 2-1. Java primitive data types
Type
Contains
Default
Size
Range
boolean true
or
false
1 bit
NA
false
Unicode character
\u0000
16 bits
\u0000
to
\uFFFF
char
Signed integer
0
8 bits
-128 to 127
byte
Signed integer
0
16 bits
-32768 to 32767
short
Signed integer
0
32 bits
-2147483648 to 2147483647
int
Signed integer
0
64 bits
-9223372036854775808 to 9223372036854775807
long
IEEE 754 loating point
0.0
32 bits
1.4E-45 to 3.4028235E+38
float
IEEE 754 loating point
0.0
64 bits
4.9E-324 to 1.7976931348623157E+308
double