Java Reference
In-Depth Information
scope of a variable
42
Unicode 62
UNIX epoch
short
type 45
supplementary Unicode
51
62
variable 35
whitespace character
system analysis
58
69
system design
58
widening (of types)
56
underflow
46
C
HAPTER
S
UMMARY
1.
Identifiers
are names for naming elements such as variables, constants, methods,
classes, packages in a program.
2.
An identifier is a sequence of characters that consists of letters, digits, underscores (
_
),
and dollar signs (
$
). An identifier must start with a letter or an underscore. It cannot start
with a digit. An identifier cannot be a reserved word. An identifier can be of any length.
3.
Variables
are used to store data in a program.
4.
To declare a variable is to tell the compiler what type of data a variable can hold.
5.
In Java, the equal sign (
=
) is used as the
assignment operator.
6.
A variable declared in a method must be assigned a value before it can be used.
7.
A
named constant
(or simply a
constant
) represents permanent data that never changes.
8.
A named constant is declared by using the keyword
final
.
9.
Java provides four integer types (
byte
,
short
,
int
, and
long
) that represent inte-
gers of four different sizes.
10.
Java provides two
floating-point types
(
float
and
double
) that represent floating-
point numbers of two different precisions.
11.
Java provides
operators
that perform numeric operations:
+
(addition),
-
(subtrac-
tion),
*
(multiplication),
/
(division), and
%
(remainder).
12.
Integer arithmetic (
/
) yields an integer result.
13.
The numeric operators in a Java expression are applied the same way as in an arith-
metic expression.
14.
Java provides the augmented assignment operators
+=
(addition assignment),
-=
(subtraction assignment),
*=
(multiplication assignment),
/=
(division assignment),
and
%=
(remainder assignment).
15.
The
increment operator
(
++
) and the
decrement operator
(
--
) increment or decre-
ment a variable by
1
.
16.
When evaluating an expression with values of mixed types, Java automatically con-
verts the operands to appropriate types.
17.
You can explicitly convert a value from one type to another using the
(type)value
notation.