Java.lang Package Classes

Java.lang.Boolean Class



Java Boolean Class

Java.lang package provides a Boolean class which wraps a value of the primitive type boolean in an object. An object of type Boolean contains a single field whose type is boolean.

In addition, this class provides many methods for converting a boolean to a String and a String to a boolean, as well as other constants and methods useful when dealing with a boolean.

Class declaration

The declaration of java.lang.Boolean class is:

public final class Boolean
  extends Object
    implements Serializable, Comparable<Boolean>

Fields

S.NFields & Description
1. static Boolean FALSE
The Boolean object corresponding to the primitive value false.
2. static Boolean TRUE
The Boolean object corresponding to the primitive value true.
3. static Class<Boolean> TYPE
The Class object representing the primitive type boolean.

java.lang.Boolean Methods

The java.lang.Boolean class has a number of methods which are listed below:

Member Methods

S.NMethods & Description
1. boolean booleanValue()
Returns the value of this Boolean object as a boolean primitive.
2. static int compare(boolean x, boolean y)
Compares two boolean values.
3. int compareTo(Boolean b)
Compares this Boolean instance with another.
4. boolean equals(Object obj)
Returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.
5. static boolean getBoolean(String name)
Returns true if and only if the system property named by the argument exists and is equal to the string "true".
6. int hashCode()
Returns a hash code for this Boolean object.
7. static int hashCode(boolean value)
Returns a hash code for a boolean value; compatible with Boolean.hashCode().
8. static boolean logicalAnd(boolean a, boolean b)
Returns the result of applying the logical AND operator to the specified boolean operands.
9. static boolean logicalOr(boolean a, boolean b)
Returns the result of applying the logical OR operator to the specified boolean operands.
10. static boolean logicalXor(boolean a, boolean b)
Returns the result of applying the logical XOR operator to the specified boolean operands.
11. static boolean parseBoolean(String s)
Parses the string argument as a boolean.
12. String toString()
Returns a String object representing this Boolean's value.
13. static String toString(boolean b)
Returns a String object representing the specified boolean.
14. static Boolean valueOf(boolean b)
Returns a Boolean instance representing the specified boolean value.
15. static Boolean valueOf(String s)
Returns a Boolean with a value represented by the specified string.

Methods inherited

This class inherits the methods of following class:

  • java.lang.Object