Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value of 'boolean' and 'Boolean' in Java

What are the default values of boolean (primitive) and Boolean (primitive wrapper) in Java?

like image 203
Makky Avatar asked Oct 11 '22 15:10

Makky


People also ask

What is the default value for Boolean?

The default value of Boolean is False . Boolean values are not stored as numbers, and the stored values are not intended to be equivalent to numbers. You should never write code that relies on equivalent numeric values for True and False .

What is the value of Boolean in Java?

A Boolean expression is a Java expression that returns a Boolean value: true or false .


1 Answers

The default value for a Boolean (object) is null.
The default value for a boolean (primitive) is false.

like image 593
Prince John Wesley Avatar answered Oct 14 '22 04:10

Prince John Wesley