java.lang
Class Boolean
- java.lang.Object
-
- java.lang.Boolean
-
public class Boolean extends Object
-
-
Field Summary
Fields Modifier and Type Field and Description static Boolean
FALSE
TheBoolean
object that represents the primitive valuefalse
.static Boolean
TRUE
TheBoolean
object that represents the primitive valuetrue
.
-
Constructor Summary
Constructors Constructor and Description Boolean(boolean value)
Constructs a newBoolean
with the specified primitive boolean value.
-
Method Summary
Methods Modifier and Type Method and Description boolean
booleanValue()
Gets the primitive value of this boolean, eithertrue
orfalse
.boolean
equals(Object o)
Compares this instance with the specified object and indicates if they are equal.int
hashCode()
Returns an integer hash code for this boolean.String
toString()
Returns a string containing a concise, human-readable description of this boolean.static Boolean
valueOf(boolean b)
Returns aBoolean
instance for the specified boolean value.
-
-
-
Field Detail
-
TRUE
public static final Boolean TRUE
TheBoolean
object that represents the primitive valuetrue
.
-
FALSE
public static final Boolean FALSE
TheBoolean
object that represents the primitive valuefalse
.
-
-
Constructor Detail
-
Boolean
public Boolean(boolean value)
Constructs a newBoolean
with the specified primitive boolean value.- Parameters:
value
- the primitive boolean value,true
orfalse
.
-
-
Method Detail
-
booleanValue
public boolean booleanValue()
Gets the primitive value of this boolean, eithertrue
orfalse
.- Returns:
- this object's primitive value,
true
orfalse
.
-
equals
public boolean equals(Object o)
Compares this instance with the specified object and indicates if they are equal. In order to be equal,o
must be an instance ofBoolean
and have the same boolean value as this object.- Overrides:
equals
in classObject
- Parameters:
o
- the object to compare this boolean with.- Returns:
true
if the specified object is equal to thisBoolean
;false
otherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Returns an integer hash code for this boolean.- Overrides:
hashCode
in classObject
- Returns:
- this boolean's hash code, which is
1231
fortrue
values and1237
forfalse
values. - See Also:
Object.equals(java.lang.Object)
-
toString
public String toString()
Returns a string containing a concise, human-readable description of this boolean.
-
valueOf
public static Boolean valueOf(boolean b)
Returns aBoolean
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.- Parameters:
b
- the boolean to convert to aBoolean
.- Returns:
Boolean.TRUE
ifb
is equal totrue
,Boolean.FALSE
otherwise.
-
-