How to Convert Boolean Object to boolean primitives

 * 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

		// 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("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");



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top Search