Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Boolean

public final class Boolean
extends Object implements Serializable, Comparable<Boolean>

java.lang.Object
   ↳ java.lang.Boolean


The wrapper for the primitive type boolean.

Summary

Fields

public static final Boolean FALSE

The Boolean object that represents the primitive value false.

public static final Boolean TRUE

The Boolean object that represents the primitive value true.

public static final Class<Boolean> TYPE

The Class object that represents the primitive type boolean.

Public constructors

Boolean(String string)

Constructs a new Boolean with its boolean value specified by string.

Boolean(boolean value)

Constructs a new Boolean with the specified primitive boolean value.

Public methods

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.

static String toString(boolean value)

Converts the specified boolean to its string representation.

String toString()

Returns a string containing a concise, human-readable description of this boolean.

static Boolean valueOf(String string)

Parses the specified string as a boolean value.

static Boolean valueOf(boolean b)

Returns a Boolean instance for the specified boolean value.

Inherited methods

From class java.lang.Object
From interface java.lang.Comparable

Fields

FALSE

Added in API level 1
Boolean FALSE

The Boolean object that represents the primitive value false.

TRUE

Added in API level 1
Boolean TRUE

The Boolean object that represents the primitive value true.

TYPE

Added in API level 1
Class<Boolean> TYPE

The Class object that represents the primitive type boolean.

Public constructors

Boolean

Added in API level 1
Boolean (String string)

Constructs a new 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.

Parameters
string String: the string representing a boolean value.

Boolean

Added in API level 1
Boolean (boolean value)

Constructs a new Boolean with the specified primitive boolean value.

Parameters
value boolean: the primitive boolean value, true or false.

Public methods

booleanValue

Added in API level 1
boolean booleanValue ()

Gets the primitive value of this boolean, either true or false.

Returns
boolean this object's primitive value, true or false.

compare

Added in API level 19
int compare (boolean lhs, 
                boolean rhs)

Compares two boolean values.

Parameters
lhs boolean
rhs boolean
Returns
int 0 if lhs = rhs, less than 0 if lhs < rhs, and greater than 0 if lhs > rhs. (Where true > false.)

compareTo

Added in API level 1
int compareTo (Boolean that)

Compares this object to the specified boolean object to determine their relative order.

Parameters
that Boolean: the boolean object to compare this object to.
Returns
int 0 if the value of this boolean and the value of 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.

See also:

equals

Added in API level 1
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 of Boolean and have the same boolean value as this object.

Parameters
o Object: the object to compare this boolean with.
Returns
boolean true if the specified object is equal to this Boolean; false otherwise.

getBoolean

Added in API level 1
boolean getBoolean (String string)

Returns the boolean value of the system property identified by string.

Parameters
string String: the name of the requested system property.
Returns
boolean true if the system property named by string exists and it is equal to "true" using case insensitive comparison, false otherwise.

See also:

hashCode

Added in API level 1
int hashCode ()

Returns an integer hash code for this boolean.

Returns
int this boolean's hash code, which is 1231 for true values and 1237 for false values.

parseBoolean

Added in API level 1
boolean parseBoolean (String s)

Parses the specified string as a boolean.

Parameters
s String: the string representation of a boolean value.
Returns
boolean true if s is not null and is equal to "true" using case insensitive comparison, false otherwise.

toString

Added in API level 1
String toString (boolean value)

Converts the specified boolean to its string representation.

Parameters
value boolean: the boolean to convert.
Returns
String "true" if value is true, "false" otherwise.

toString

Added in API level 1
String toString ()

Returns a string containing a concise, human-readable description of this boolean.

Returns
String "true" if the value of this boolean is true, "false" otherwise.

valueOf

Added in API level 1
Boolean valueOf (String string)

Parses the specified string as a boolean value.

Parameters
string String: the string representation of a boolean value.
Returns
Boolean Boolean.TRUE if string is equal to "true" using case insensitive comparison, Boolean.FALSE otherwise.

See also:

valueOf

Added in API level 1
Boolean valueOf (boolean b)

Returns a 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.

Parameters
b boolean: the boolean to convert to a Boolean.
Returns
Boolean Boolean.TRUE if b is equal to true, Boolean.FALSE otherwise.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.