Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Boolean.booleanValue() method is used to return the value of this Boolean object as a boolean primitive.

Syntax

public boolean booleanValue()

Parameters

No parameter is required.

Return Value

Returns the primitive boolean value of this object.

Exception

NA.

Example:

In the below example, the java.lang.Boolean.booleanValue() method is used to return a Boolean object after conversion to type boolean.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating Boolean objects
    Boolean b1 = new Boolean("true");
    Boolean b2 = new Boolean(false);

    //printing booleanValue of the Boolean objects
    System.out.println("booleanValue of the b1 is: " + b1.booleanValue()); 
    System.out.println("booleanValue of the b2 is: " + b2.booleanValue());   
  }
}

The output of the above code will be:

booleanValue of the b1 is: true
booleanValue of the b2 is: false

❮ Java.lang - Boolean