Java Boolean Class

tutorial and example
tutorial and example

The Boolean class wraps a value of the Boolean primitive in an object. Its object contains only a single field whose type is Boolean.

Boolean Methods:

This class contains several different methods and other constants for converting Boolean to a string and vice versa and also many other methods which are useful dealing with a Boolean.

Methods Description
booleanValue() It returns a Boolean value for the Boolean arguments.
compare() It compares the two Boolean arguments.
compareTo() It compares the given Boolean instance with another.
equals() It returns a Boolean value true only if the specified argument is not null and the Boolean argument represents the same value as the object.
getBoolean() It returns a Boolean value true if and only if the system property name is not null and is equal to  ”true”.
hashCode() It returns a hash code for the specified Boolean object.
logicalAnd() It returns the result after implementing logical AND operation on the Boolean arguments.
logicalOr() It returns the result after implementing logical OR operation on the specified Boolean arguments.
logicalXor() It returns the result after implementing logical XOR operation on the Boolean arguments.
parseBoolean() It returns a Boolean value represented by the string argument by parsing the string argument as a Boolean.
toString() It returns a String instance representing the specified Boolean’s value.
valueOf() It returns a Boolean instance representing the given string or Boolean value.

 Example 1:

Output:

Example 2:

Output: