Packages This Package Prev Next Index
§1.1 Class Boolean
public final class java.lang.Boolean
extends java.lang.Object (I-§1.12)
{
// Fields
public final static Boolean FALSE; §1.1.1
public final static Boolean TRUE; §1.1.2
// Constructors
public Boolean(boolean value); §1.1.3
public Boolean(String s); §1.1.4
// Methods
public boolean booleanValue(); §1.1.5
public boolean equals(Object obj); §1.1.6
public static boolean getBoolean(String name); §1.1.7
public int hashCode(); §1.1.8
public String toString(); §1.1.9
public static Boolean valueOf(String s); §1.1.10
}
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.
FALSE
public final static Boolean FALSE = new Boolean(false)
- The Boolean object corresponding to the primitive value false.
TRUE
public final static Boolean TRUE = new Boolean(true)
- The Boolean object corresponding to the primitive value true.
Boolean
public Boolean(boolean value)
- Allocates a Boolean object representing the value argument.
- Parameters:
value
-
the value of the boolean
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.
- Parameters:
s
-
the string to be converted to a Boolean
booleanValue
public boolean booleanValue()
- Returns:
- the primitive boolean value of this object.
equals
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.
- Parameters:
obj
-
the object to compare with
- Returns:
- true if the objects are the same; false otherwise.
- Overrides:
- equals in class Object (I-§1.12.3).
getBoolean
public static boolean getBoolean(String name)
- The result is true if and only if the system property (I-§1.18.9) named by
the argument exists and is equal, ignoring case1, to the string "true".
- Parameters:
name
-
the system property name
- Returns:
- the boolean value of the system property.
hashCode
public int hashCode()
- Returns:
- a hash code value for this object.
- Overrides:
- hashCode in class Object (I-§1.12.6).
toString
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.
- Returns:
- a string representation of this object.
- Overrides:
- toString in class Object (I-§1.12.9).
valueOf
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".
- Parameters:
s
-
a string
- Returns:
- The Boolean value represented by the 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.
Packages This Package Prev Next Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc.
All rights reserved
Please send any comments or corrections to doug.kramer@sun.com