Boolean

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

The 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.

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.

Field Summary

public static final Boolean FALSE The Boolean object corresponding to the primitive value false.
public static final Boolean TRUE The Boolean object corresponding to the primitive value true.
public static final Class<Boolean> TYPE The Class object representing the primitive type boolean.

Public Constructor Summary

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".

Public Method Summary

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 int
hashCode(boolean value)
Returns a hash code for a boolean value; compatible with Boolean.hashCode().
static boolean
logicalAnd(boolean a, boolean b)
Returns the result of applying the logical AND operator to the specified boolean operands.
static boolean
logicalOr(boolean a, boolean b)
Returns the result of applying the logical OR operator to the specified boolean operands.
static boolean
logicalXor(boolean a, boolean b)
Returns the result of applying the logical XOR operator to the specified boolean operands.
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(String s)
Returns a Boolean with a value represented by the specified string.
static Boolean
valueOf(boolean b)
Returns a Boolean instance representing the specified boolean value.

Inherited Method Summary

Fields

public static final Boolean FALSE

The Boolean object corresponding to the primitive value false.

public static final Boolean TRUE

The Boolean object corresponding to the primitive value true.

public static final Class<Boolean> TYPE

The Class object representing the primitive type boolean.

Public Constructors

public Boolean (boolean value)

Allocates a Boolean object representing the value argument.

Note: It is rarely appropriate to use this constructor. Unless a new instance is required, the static factory valueOf(boolean) is generally a better choice. It is likely to yield significantly better space and time performance.

Parameters
value the value of the Boolean.

public 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". Otherwise, allocate a Boolean object representing the value false. Examples:

new Boolean("True") produces a Boolean