In this post, we will see what is default value of boolean and Boolean in java.
💡 Did you know?
The Default value of
booleanisfalseand wrapper classBooleanisnull.
Here is the example to demonstrate the same.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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
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.
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.