public final class Boolean extends Object implements Serializable, Comparable<Boolean>
Boolean
represent primitive
boolean
values.Modifier and Type | Field and Description |
---|---|
static Boolean |
FALSE
This field is a
Boolean object representing the
primitive value false . |
static Boolean |
TRUE
This field is a
Boolean object representing the
primitive value true . |
static Class<Boolean> |
TYPE
The primitive type
boolean is represented by this
Class object. |
Constructor and Description |
---|
Boolean(boolean value)
Create a
Boolean object representing the value of the
argument value . |
Boolean(String s)
Creates a
Boolean object representing the primitive
true if and only if s matches
the string "true" ignoring case, otherwise the object will represent
the primitive false . |
Modifier and Type | Method and Description |
---|---|
boolean |
booleanValue()
Return the primitive
boolean value of this
Boolean object. |
int |
compareTo(Boolean other)
Compares this Boolean to another.
|
boolean |
equals(Object obj)
If the
obj is an instance of Boolean and
has the same primitive value as this object then true
is returned. |
static boolean |
getBoolean(String name)
If the value of the system property
name matches
"true" ignoring case then the function returns true . |
int |
hashCode()
Returns the integer
1231 if this object represents
the primitive true and the integer 1237
otherwise. |
static boolean |
parseBoolean(String b)
If the String argument is "true", ignoring case, return true.
|
String |
toString()
Returns "true" if the value of this object is
true and
returns "false" if the value of this object is false . |
static String |
toString(boolean b)
Returns "true" if the value of the give boolean is
true and
returns "false" if the value of the given boolean is false . |
static Boolean |
valueOf(boolean b)
Returns the Boolean
TRUE if the given boolean is
true , otherwise it will return the Boolean
FALSE . |
static Boolean |
valueOf(String s)
Returns the Boolean
TRUE if and only if the given
String is equal, ignoring case, to the the String "true", otherwise
it will return the Boolean FALSE . |
public static final Boolean TRUE
Boolean
object representing the
primitive value true
. This instance is returned
by the static valueOf()
methods if they return
a Boolean
representing true
.public static final Boolean FALSE
Boolean
object representing the
primitive value false
. This instance is returned
by the static valueOf()
methods if they return
a Boolean
representing false
.public Boolean(boolean value)
Boolean
object representing the value of the
argument value
. In general the use of the static
method valueof(boolean)
is more efficient since it will
not create a new object.value
- the primitive value of this Boolean
valueOf(boolean)
public Boolean(String s)
Boolean
object representing the primitive
true
if and only if s
matches
the string "true" ignoring case, otherwise the object will represent
the primitive false
. In general the use of the static
method valueof(String)
is more efficient since it will
not create a new object.s
- the String
representation of true
or falsepublic boolean booleanValue()
boolean
value of this
Boolean
object.public static Boolean valueOf(boolean b)
TRUE
if the given boolean is
true
, otherwise it will return the Boolean
FALSE
.public static Boolean valueOf(String s)
TRUE
if and only if the given
String is equal, ignoring case, to the the String "true", otherwise
it will return the Boolean FALSE
.s
- the string to convertpublic static String toString(boolean b)
true
and
returns "false" if the value of the given boolean is false
.b
- the boolean to convertpublic String toString()
true
and
returns "false" if the value of this object is false
.toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)
public int hashCode()
1231
if this object represents
the primitive true
and the integer 1237
otherwise.hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public boolean equals(Object obj)
obj
is an instance of Boolean
and
has the same primitive value as this object then true
is returned. In all other cases, including if the obj
is null
, false
is returned.equals
in class Object
obj
- possibly an instance of any Class
obj
equals thisObject.hashCode()
public static boolean getBoolean(String name)
name
matches
"true" ignoring case then the function returns true
.name
- the property name to look upSecurityException
- if accessing the system property is forbiddenSystem.getProperty(String)
public int compareTo(Boolean other)
compareTo
in interface Comparable<Boolean>
other
- the Boolean to compare this Boolean topublic static boolean parseBoolean(String b)
b
- String to parse