/*
* Here we will learn to convert Boolean Object to boolean primitives
*/
public class ConvertBooleanPrimitives {
public static void main(String[] args) {
/*
* Boolean constructor with String argument allocates a Boolean object
* representing the value true if the string argument is not null and is
* equal(Ignoring case) to the string "true".
*
* Otherwise, for any other thing it allocates a Boolean object
* representing the value as false.
*/
Boolean boolObjectFalse = new Boolean("");
Boolean boolObjectFalse1 = new Boolean("Any Value other then true");
// Both two Object above will have value as False
System.out.println(boolObjectFalse);
System.out.println(boolObjectFalse1);
// Note*: Here String is compared to true ignoring case
Boolean boolObjectTrue = new Boolean("trUe");
// Above object will have value as true coz string argument is
// true(ignoring case)
System.out.println(boolObjectTrue);
System.out.println("Converting Boolean Object to boolean Primitives");
/*
* boolean booleanValue() method will returns the value of this Boolean
* object as a boolean primitive.
*/
boolean boolPrimitivesFalse = boolObjectFalse.booleanValue();
boolean boolPrimitivesTrue = boolObjectTrue.booleanValue();
System.out.println("Value of boolean primitive is");
System.out.println(boolPrimitivesFalse);
System.out.println(boolPrimitivesTrue);
}
}