Description
Program to convert Boolean object to boolean primitive in java
Example
class BooleanObjToBooleanPrim { public static void main(String[] args) { // Creating an object of Boolean Class Boolean bObj = new Boolean("true"); // Case does not matter Boolean bObj2 = new Boolean("FaLsE"); /* Boolean object to boolean conversion * using booleanValue() method */ boolean bvar = bObj.booleanValue(); System.out.println("boolean value is: "+bvar); boolean bvar2 = bObj2.booleanValue(); System.out.println("boolean value is: "+bvar2); } }
Output:
boolean value is: true boolean value is: false
public boolean booleanValue()
: Returns the value of this Boolean object as a boolean primitive. Source.
Leave a Reply