
8.1 Declaring and Instantiating Arrays 467
TABLE 8.1 Default Initial Values of Array Elements
Element Data Type Initial Value
double 0.0
float 0.0
int,long,short,byte 0
char space
boolean false
object reference null
When an array is instantiated, the elements are given initial values auto-
matically.
Numeric elements are set to 0, boolean elements are set to false, char ele-
ments are set to a space, and object references are set to null, as shown in
Table 8.1.
Thus, all the elements in the dailyTemps array are given an initial value of
0.0; the elements in the cs101, bio201, and hist102 arrays are given an initial
value of 0; the elements of the answers