public final class Boolean extends Object implements Serializable, Comparable<Boolean>
boolean
.Modifier and Type | Field and Description |
---|---|
static Boolean |
FALSE
The
Boolean object that represents the primitive value
false . |
static Boolean |
TRUE
The
Boolean object that represents the primitive value
true . |
static Class<Boolean> |
TYPE
The
Class object that represents the primitive type boolean . |
Constructor and Description |
---|
Boolean(boolean value)
Constructs a new
Boolean with the specified primitive boolean
value. |
Boolean(String string)
Constructs a new
Boolean with its boolean value specified by
string . |
Modifier and Type | Method and Description |
---|---|
boolean |
booleanValue()
Gets the primitive value of this boolean, either
true or
false . |
static int |
compare(boolean lhs,
boolean rhs)
Compares two
boolean values. |
int |
compareTo(Boolean that)
Compares this object to the specified boolean object to determine their
relative order.
|
boolean |
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
static boolean |
getBoolean(String string)
Returns the
boolean value of the system property identified by
string . |
int |
hashCode()
Returns an integer hash code for this boolean.
|
static boolean |
parseBoolean(String s)
Parses the specified string as a
boolean . |
String |
toString()
Returns a string containing a concise, human-readable description of this
boolean.
|
static String |
toString(boolean value)
Converts the specified boolean to its string representation.
|
static Boolean |
valueOf(boolean b)
Returns a
Boolean instance for the specified boolean value. |
static Boolean |
valueOf(String string)
Parses the specified string as a boolean value.
|
public static final Class<Boolean> TYPE
Class
object that represents the primitive type boolean
.public static final Boolean TRUE
Boolean
object that represents the primitive value
true
.public static final Boolean FALSE
Boolean
object that represents the primitive value
false
.public Boolean(String string)
Boolean
with its boolean value specified by
string
. If string
is not null
and is equal to
"true" using a non-case sensitive comparison, the result will be a
Boolean representing the primitive value true
, otherwise it will
be a Boolean representing the primitive value false
.string
- the string representing a boolean value.public Boolean(boolean value)
Boolean
with the specified primitive boolean
value.value
- the primitive boolean value, true
or false
.public boolean booleanValue()
true
or
false
.true
or false
.public boolean equals(Object o)
o
must be an instance of
Boolean
and have the same boolean value as this object.equals
in class Object
o
- the object to compare this boolean with.true
if the specified object is equal to this
Boolean
; false
otherwise.Object.hashCode()
public int compareTo(Boolean that)
compareTo
in interface Comparable<Boolean>
that
- the boolean object to compare this object to.that
are
equal; a positive value if the value of this boolean is
true
and the value of that
is false
; a
negative value if the value if this boolean is false
and
the value of that
is true
.Comparable
public static int compare(boolean lhs, boolean rhs)
boolean
values.public int hashCode()
hashCode
in class Object
1231
for true
values and 1237
for false
values.Object.equals(java.lang.Object)
public String toString()
public static boolean getBoolean(String string)
boolean
value of the system property identified by
string
.string
- the name of the requested system property.true
if the system property named by string
exists and it is equal to "true" using case insensitive
comparison, false
otherwise.System.getProperty(String)
public static boolean parseBoolean(String s)
boolean
.s
- the string representation of a boolean value.true
if s
is not null
and is equal to
"true"
using case insensitive comparison, false
otherwise.public static String toString(boolean value)
value
- the boolean to convert.value
is true
, "false" otherwise.public static Boolean valueOf(String string)
string
- the string representation of a boolean value.Boolean.TRUE
if string
is equal to "true" using
case insensitive comparison, Boolean.FALSE
otherwise.parseBoolean(String)
public static Boolean valueOf(boolean b)
Boolean
instance for the specified boolean value.
If it is not necessary to get a new Boolean
instance, it is
recommended to use this method instead of the constructor, since it
returns its static instances, which results in better performance.
b
- the boolean to convert to a Boolean
.Boolean.TRUE
if b
is equal to true
,
Boolean.FALSE
otherwise.