java.lang.Boolean booleanValue()


The booleanValue() method of Boolean class is use to get the primitive equivalent of this Boolean object. This method will yield the same result if you use the unboxing concept of java. Let’s say we have declared Boolean value = true then both of the following statement will yield the same result

boolean primitiveVal = value.booleanValue()


boolean primitiveVal = value

The unboxing feature of java will take care of the conversion of Boolean object to its primitive data type.

Method Syntax

public boolean booleanValue()

Method Argument

Data Type Parameter Description

Method Returns

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

Java Boolean booleanValue() Example

Below is a simple java example on the usage of booleanValue() method of Boolean class.


 * This example source code demonstrates the use of 
 * booleanValue() method of Boolean class.

public class BooleanValueExample {

	public static void main(String[] args) {
		// instantiate a new Boolean object
		Boolean boolObject = new Boolean(true);
		// convert boolObject to boolean primitive
		boolean boolPrimitive = boolObject.booleanValue();
		// test equality of the two value
		if(boolPrimitive == boolObject){
			System.out.println("they are equal");
			System.out.println("they are not equal");


Sample Output

The following is the sample output if you run the sample code:

java Boolean booleanValue() example output