How to Convert String Object to Boolean Object

 * Here we will learn to convert String Object to Boolean Object.
public class ConvertStringToBoolean {

	public static void main(String[] args) {

		String strBoolFalse = "garbage value";

		String strBoolFalse1 = "";

		// String will be compared with "true" value ignoring case.
		String strBoolTrue = "trUE";

		 * 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 false.
		Boolean boolObjectTrue = new Boolean(strBoolTrue);
		Boolean boolObjectFalse = new Boolean(strBoolFalse);
		Boolean boolObjectFalse1 = new Boolean(strBoolFalse1);

		// Both two Object above will have value as False



By | 2017-07-24T12:48:53+00:00 October 1st, 2012|Code Base|0 Comments

About the Author:

Leave A Comment