Boolean (Java SE 17 & JDK 17) (original) (raw)

All Implemented Interfaces:

[Serializable](../io/Serializable.html "interface in java.io"), [Comparable](Comparable.html "interface in java.lang")<[Boolean](Boolean.html "class in java.lang")>, [Constable](constant/Constable.html "interface in java.lang.constant")


The Boolean class wraps a value of the primitive typeboolean in an object. An object of typeBoolean contains a single field whose type isboolean.

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

This is a value-based class; programmers should treat instances that areequal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail.

Since:

1.0

See Also:

Fields
The Boolean object corresponding to the primitive value false.
The Boolean object corresponding to the primitive value true.
The Class object representing the primitive type boolean.

Constructors
[Boolean](#%3Cinit%3E%28boolean%29)(boolean value)
Deprecated, for removal: This API element is subject to removal in a future version.
Deprecated, for removal: This API element is subject to removal in a future version.

boolean
Returns the value of this Boolean object as a boolean primitive.
static int
[compare](#compare%28boolean,boolean%29)(boolean x, boolean y)
Compares two boolean values.
int
Compares this Boolean instance with another.
Returns an Optional containing the nominal descriptor for this instance.
boolean
Returns true if and only if the argument is notnull and is a Boolean object that represents the same boolean value as this object.
static boolean
Returns true if and only if the system property named by the argument exists and is equal to, ignoring case, the string "true".
int
[hashCode](#hashCode%28%29)()
Returns a hash code for this Boolean object.
static int
[hashCode](#hashCode%28boolean%29)(boolean value)
Returns a hash code for a boolean value; compatible withBoolean.hashCode().
static boolean
[logicalAnd](#logicalAnd%28boolean,boolean%29)(boolean a, boolean b)
Returns the result of applying the logical AND operator to the specified boolean operands.
static boolean
[logicalOr](#logicalOr%28boolean,boolean%29)(boolean a, boolean b)
Returns the result of applying the logical OR operator to the specified boolean operands.
static boolean
[logicalXor](#logicalXor%28boolean,boolean%29)(boolean a, boolean b)
Returns the result of applying the logical XOR operator to the specified boolean operands.
static boolean
Parses the string argument as a boolean.
[toString](#toString%28%29)()
Returns a String object representing this Boolean's value.
[toString](#toString%28boolean%29)(boolean b)
Returns a String object representing the specified boolean.
[valueOf](#valueOf%28boolean%29)(boolean b)
Returns a Boolean instance representing the specifiedboolean value.
Returns a Boolean with a value represented by the specified string.