Default value of 'boolean' and 'Boolean' in Java
The default value for a Boolean
(object) is null
.
The default value for a boolean
(primitive) is false
.
The default value of any Object
, such as Boolean
, is null
.
The default value for a boolean
is false.
Note: Every primitive has a wrapper class. Every wrapper uses a reference which has a default of null
. Primitives have different default values:
boolean -> false
byte, char, short, int, long -> 0
float, double -> 0.0
Note (2): void
has a wrapper Void
which also has a default of null
and is it's only possible value (without using hacks).