Home » openjdk-7 » java » lang » [javadoc | source]
java.lang
public final class: Boolean [javadoc | source]
java.lang.Object
   java.lang.Boolean

All Implemented Interfaces:
    Comparable, Serializable

The Boolean class wraps a value of the primitive type {@code boolean} in an object. An object of type {@code Boolean} contains a single field whose type is {@code boolean}.

In addition, this class provides many methods for converting a {@code boolean} to a {@code String} and a {@code String} to a {@code boolean}, as well as other constants and methods useful when dealing with a {@code boolean}.

Field Summary
public static final  Boolean TRUE    The {@code Boolean} object corresponding to the primitive value {@code true}. 
public static final  Boolean FALSE    The {@code Boolean} object corresponding to the primitive value {@code false}. 
public static final  Class<Boolean> TYPE    The Class object representing the primitive type boolean.
    since: JDK1.1 -
 
Constructor:
 public Boolean(boolean value) 
    Parameters:
    value - the value of the {@code Boolean}.
 public Boolean(String s) 
    Allocates a {@code Boolean} object representing the value {@code true} if the string argument is not {@code null} and is equal, ignoring case, to the string {@code "true"}. Otherwise, allocate a {@code Boolean} object representing the value {@code false}. Examples:

    {@code new Boolean("True")} produces a {@code Boolean} object that represents {@code true}.
    {@code new Boolean("yes")} produces a {@code Boolean} object that represents {@code false}.

    Parameters:
    s - the string to be converted to a {@code Boolean}.
Method from java.lang.Boolean Summary:
booleanValue,   compare,   compareTo,   equals,   getBoolean,   hashCode,   parseBoolean,   toString,   toString,   valueOf,   valueOf
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.lang.Boolean Detail:
 public boolean booleanValue() 
    Returns the value of this {@code Boolean} object as a boolean primitive.
 public static int compare(boolean x,
    boolean y) 
    Compares two {@code boolean} values. The value returned is identical to what would be returned by:
       Boolean.valueOf(x).compareTo(Boolean.valueOf(y))
    
 public int compareTo(Boolean b) 
    Compares this {@code Boolean} instance with another.
 public boolean equals(Object obj) 
    Returns {@code true} if and only if the argument is not {@code null} and is a {@code Boolean} object that represents the same {@code boolean} value as this object.
 public static boolean getBoolean(String name) 
    Returns {@code true} if and only if the system property named by the argument exists and is equal to the string {@code "true"}. (Beginning with version 1.0.2 of the JavaTM platform, the test of this string is case insensitive.) A system property is accessible through {@code getProperty}, a method defined by the {@code System} class.

    If there is no property with the specified name, or if the specified name is empty or null, then {@code false} is returned.

 public int hashCode() 
    Returns a hash code for this {@code Boolean} object.
 public static boolean parseBoolean(String s) 
    Parses the string argument as a boolean. The {@code boolean} returned represents the value {@code true} if the string argument is not {@code null} and is equal, ignoring case, to the string {@code "true"}.

    Example: {@code Boolean.parseBoolean("True")} returns {@code true}.
    Example: {@code Boolean.parseBoolean("yes")} returns {@code false}.

 public String toString() 
    Returns a {@code String} object representing this Boolean's value. If this object represents the value {@code true}, a string equal to {@code "true"} is returned. Otherwise, a string equal to {@code "false"} is returned.
 public static String toString(boolean b) 
    Returns a {@code String} object representing the specified boolean. If the specified boolean is {@code true}, then the string {@code "true"} will be returned, otherwise the string {@code "false"} will be returned.
 public static Boolean valueOf(boolean b) 
    Returns a {@code Boolean} instance representing the specified {@code boolean} value. If the specified {@code boolean} value is {@code true}, this method returns {@code Boolean.TRUE}; if it is {@code false}, this method returns {@code Boolean.FALSE}. If a new {@code Boolean} instance is not required, this method should generally be used in preference to the constructor #Boolean(boolean) , as this method is likely to yield significantly better space and time performance.
 public static Boolean valueOf(String s) 
    Returns a {@code Boolean} with a value represented by the specified string. The {@code Boolean} returned represents a true value if the string argument is not {@code null} and is equal, ignoring case, to the string {@code "true"}.