The default initial value of several java arrays

1. Analysis

Because it is in the heap, jvm will automatically assign values ​​to the array when new.
1. Array defined by int type, initialized to 0 by default

2. Array defined by String type, the default value is null

3. Array defined by char type, the default value is the character corresponding to 0

4. Array defined by type double, the default value is 0.0

5. Array defined by float type, the default value is 0.0

6. Array defined by boolean type, the default value is false

Guess you like

Origin blog.csdn.net/qq_44688861/article/details/105068120