The Boolean class as part of the java.lang package is one of the classes of the java api that is being widely used. Let’s tackle the basics of using the Boolean class. Let’s discuss first how to instantiate a Boolean object
Boolean value = new Boolean(true);
Basically the declaration of a Boolean object is almost the same as we are doing in assigning primitive data type boolean. Similarly to boolean primitive the Boolean object has only two possible values, which is either true or false. This is a straightforward method to instantiate a Boolean object type. Let’s take another way to do this.
The 2nd method is using the autoboxing concept of java programming language which directly converts a primitive data type to its corresponding wrapper class. If you would like to go more into details, I am recommending for you to read the official java documentation regarding autoboxing and unboxing.
There are two constructor available to Boolean class which we can use to instantiate a Boolean object:
||Allocates a Boolean object representing the value 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”.
We already discussed on how to use the Boolean(boolean value) in instantiating a Float object. So basically the other constructors usage is almost the same only in the other case, the input is in String format.