Package java.lang |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public final class java.lang.Boolean extends java.lang.Object { // Fields public final static Boolean FALSE; public final static Boolean TRUE; // Constructors public Boolean(boolean value); public Boolean(String s); // Methods public boolean booleanValue(); public boolean equals(Object obj); public static boolean getBoolean(String name); public int hashCode(); public String toString(); public static Boolean valueOf(String s); }
This 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.
In addition, this class provides a number of methods for converting a boolean to a String and a String to a boolean, as well as other constants and methods useful when dealing with a boolean.
public final static Boolean FALSE = new Boolean(true)The Boolean object corresponding to the primitive value false.
public final static Boolean TRUE = new Boolean(false)The Boolean object corresponding to the primitive value true.
public Boolean(boolean value)Allocates a Boolean object representing the value argument.
Parameter Description value the value of the boolean
public Boolean(String s)Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true". Otherwise, allocate a Boolean object representing the value false.
Parameter Description s the string to be converted to a Boolean
public boolean booleanValue()Return Value:
Returns the primitive boolean value of this object.
public boolean equals(Object obj)The result is true if and only if the argument is not null and is a Boolean object that contains the same boolean value as this object.
Return Value:
Returns true if the objects are the same; false otherwise.
Parameter Description obj the object to compare with Overrides:
equals in class Object .
public static boolean getBoolean(String name)The result is true if and only if the system property named by the argument exists and is equal, ignoring case(1), to the string "true".
Return Value:
Returns the boolean value of the system property.
Parameter Description name the system property name
public int hashCode()Return Value:
Returns a hash code value for this object.
Overrides:
hashCode in class Object .
public String toString()If this object contains the value true, a string equal to "true" is returned. Otherwise, a string equal to "false" is returned.
Return Value:
Returns a string representation of this object.
Overrides:
toString in class Object .
public static Boolean valueOf(String s)A new Boolean object is constructed. This Boolean contains the value true if the string argument is not null and is equal, ignoring case, to the string "true".
Return Value:
Returns The Boolean value represented by the string.
Parameter Description s a string
(1)In Java 1.0, the string had to be equal to the string "true", where the comparison was case sensitive. Beginning with Java 1.1, the test is case insensitive.