There are three types of variables:
- Instance variables: are always initialized
- Static variables: are always initialized
- Local variables: must be initialized before use
The default values for instance and static variables are the same and depends on the type:
- Object type (String, Integer, Boolean and others): initialized with null
- Primitive types:
- byte, short, int, long: 0
- float, double: 0.0
- boolean: false
- char: '\u0000'
An array is an Object. So an array instance variable that is declared but no explicitly initialized will have null value. If you declare an int[] array as instance variable it will have the null value.
Once the array is created all of its elements are assiged with the default type value. For example:
private boolean[] list; // default value is null
private Boolean[] list; // default value is null
once is initialized:
private boolean[] list = new boolean[10]; // all ten elements are assigned to false
private Boolean[] list = new Boolean[10]; // all ten elements are assigned to null (default Object/Boolean value)