Java Boolean.booleanValue() Method Example

The Boolean.booleanValue() method returns the value of this Boolean object as a boolean primitive.

Java Boolean.booleanValue() Method Example

public class BooleanClassExample {
 
 public static void main(String[] args) {
  booleanValue();
 }
 
 private static void booleanValue(){
   // creating different Boolean objects
        Boolean b1 = new Boolean("True");
        Boolean b2 = new Boolean("False");
        Boolean b3 = new Boolean("source code examples");
         
        // getting primitive boolean value
        boolean b4 = b1.booleanValue();
        boolean b5 = b2.booleanValue();
        boolean b6 = b3.booleanValue();
         
        System.out.println(b4);
        System.out.println(b5);
        System.out.println(b6);
 }
}
Output:
true
false
false

Reference


Comments