Class Boolean
java.lang.Object
java.lang.Boolean
- All Implemented Interfaces:
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.
Since: JDK1.0, CLDC 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of this Boolean object as a boolean primitive.static intcompare(boolean x, boolean y) 0 when equal, otherwise positive whenxis true.intCompares this object to the specified object to determine their relative order.booleanReturns 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 booleangetBoolean(String name) Whether the system propertynameis"true", ignoring case.inthashCode()Returns a hash code for this Boolean object.static inthashCode(boolean value) 1231 for true, 1237 for false, as the JDK hashes them.static booleanlogicalAnd(boolean a, boolean b) a && b.static booleanlogicalOr(boolean a, boolean b) a || b.static booleanlogicalXor(boolean a, boolean b) a ^ b.static booleantoString()Returns a String object representing this Boolean's value.static StringtoString(boolean b) "true"or"false".static BooleanvalueOf(boolean b) Returns the object instance of istatic Boolean
-
Field Details
-
FALSE
The Boolean object corresponding to the primitive value false. -
TRUE
The Boolean object corresponding to the primitive value true. -
TYPE
-
-
Constructor Details
-
Boolean
public Boolean(boolean value) Allocates a Boolean object representing the value argument. value - the value of the Boolean. -
Boolean
-
-
Method Details
-
booleanValue
public boolean booleanValue()Returns the value of this Boolean object as a boolean primitive. -
equals
-
hashCode
-
toString
-
valueOf
Returns the object instance of i
Parameters
b: the primitive
Returns
object instance
-
valueOf
-
parseBoolean
-
compareTo
Description copied from interface:ComparableCompares this object to the specified object to determine their relative order.
Parameters
another: the object to compare to this instance.
Returns
- Specified by:
compareToin interfaceComparable<Boolean>- Returns:
a negative integer if this instance is less than
another; a positive integer if this instance is greater thananother; 0 if this instance has the same order asanother.Throws
ClassCastException: @throws ClassCastException ifanothercannot be converted into something comparable tothisinstance.
-
toString
"true"or"false". -
hashCode
public static int hashCode(boolean value) 1231 for true, 1237 for false, as the JDK hashes them. -
compare
public static int compare(boolean x, boolean y) 0 when equal, otherwise positive whenxis true. -
logicalAnd
public static boolean logicalAnd(boolean a, boolean b) a && b. -
logicalOr
public static boolean logicalOr(boolean a, boolean b) a || b. -
logicalXor
public static boolean logicalXor(boolean a, boolean b) a ^ b. -
getBoolean
Whether the system propertynameis"true", ignoring case.
-