Java boolean default value

In this post, we will see what is default value of boolean and Boolean in java.

💡 Did you know?

The Default value of boolean is false and wrapper class Boolean is null.

Here is the example to demonstrate the same.

package org.arpit.java2blog;

public class JavaBooleanDefaultMain {

    boolean defaultBoolean;
    Boolean defaultBooleanWrapper;

    public static void main(String[] args) {
        JavaBooleanDefaultMain jbd=new JavaBooleanDefaultMain();
        jbd.printBooleanDefaultValues();
    }

    public void printBooleanDefaultValues()
    {
        System.out.println("Default value of boolean: "+defaultBoolean);
        System.out.println("Default value of Boolean(Wrapper): "+defaultBooleanWrapper);
    }

}

Output:

Default value of boolean: false
Default value of Boolean(Wrapper): null

As you can see default value of boolean is false and Boolean is null.

That’s all about Java boolean default value.

[social_share share_on="facebook,twitter,linkedin,whatsapp"][post_navigator in_same_term="true"]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.