Java Array Initial Values
Description
After we allocate memory for a Java array, Java assigns each element in an array to its initial values
Initial value
The initial value is zero in the case of an array of numerical values, is false for boolean arrays, is '\u0000' for arrays storing type char, and is null for an array of objects of a class type.
The following table lists the default value for various array types.
Element Type | Initial Value |
---|---|
byte | 0 |
int | 0 |
float | 0.0f |
char | '\u0000' |
object reference | null |
short | 0 |
long | 0L |
double | 0.0d |
boolean | false |