Java Reference
In-Depth Information
being explicitly declared
final
. Such a parameter is never implicitly declared
final
.
4.12.5. Initial Values of Variables
Every variable in a program must have a value before its value is used:
• Each class variable, instance variable, or array component is initialized with a
de-
♦ For type
byte
, the default value is zero, that is, the value of
(byte)0
.
♦ For type
short
, the default value is zero, that is, the value of
(short)0
.
♦ For type
int
, the default value is zero, that is,
0
.
♦ For type
long
, the default value is zero, that is,
0L
.
♦ For type
float
, the default value is positive zero, that is,
0.0f
.
♦ For type
double
, the default value is positive zero, that is,
0.0d
.
♦ For type
char
, the default value is the null character, that is,
'\u0000'
.
♦ For type
boolean
, the default value is
false
.
• Each method parameter (§
8.4.1
) is initialized to the corresponding argument value
provided by the invoker of the method (§
15.12
).
• Each constructor parameter (§
8.8.1
) is initialized to the corresponding argument
value provided by a class instance creation expression (§
15.9
) or explicit con-
using the rules for definite assignment (§16).
Example 4.12.5-1. Initial Values of Variables
class Point {
static int npoints;