The java.lang.Boolean class wraps a value of the primitive type boolean in an object. An object of type Boolean contains a single field whose type is boolean. 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.
Boolean class implements Comparable Interface that’s help while sorting list of Objects on natural order.
See Also:
- How to Sort By Comparable Interface in Ascending and Descending Order : Java
- Sort ArrayList in Ascending or Descending Order or Natural or Chronological Order
Constants
- static Boolean FALSE :The Boolean object corresponding to the primitive value false.
- static Boolean TRUE :The Boolean object corresponding to the primitive value true.
- static Class TYPE :The Class object representing the primitive type boolean.
Constructors
- Boolean(boolean value) :Allocates a Boolean object representing the value argument.
Boolean(String s) :Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string “true”.
Methods
- boolean booleanValue() :Returns the value of this Boolean object as a boolean primitive.
- static int compare(boolean x, boolean y) :Compares two boolean values.
- int compareTo(Boolean b) :Compares this Boolean instance with another.
- 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.
- 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”.
- int hashCode() :Returns a hash code for this Boolean object.
- static boolean parseBoolean(String s) :Parses the string argument as a boolean.
- String toString() :Returns a String object representing this Boolean’s value.
- static String toString(boolean b) :Returns a String object representing the specified boolean.
- static Boolean valueOf(boolean b) :Returns a Boolean instance representing the specified boolean value.
- static Boolean valueOf(String s) :Returns a Boolean with a value represented by the specified string.
You must log in to post a comment.