Team LiB
Previous Section Next Section

Booleanjava.lang

Java 1.0serializable comparable

This class provides an immutable object wrapper around the boolean primitive type. Note that the trUE and FALSE constants are Boolean objects; they are not the same as the TRue and false boolean values. As of Java 1.1, this class defines a Class constant that represents the boolean type. booleanValue( ) returns the boolean value of a Boolean object. The class method getBoolean( ) retrieves the boolean value of a named property from the system property list. The static method valueOf( ) parses a string and returns the Boolean object it represents. Java 1.4 added two static methods that convert primitive boolean values to Boolean and String objects. In Java 5.0, the parseBoolean( ) method behaves like valueOf( ) but returns a primitive boolean value instead of a Boolean object.

Prior to Java 5.0, this class does not implement the Comparable interface.

Figure 10-7. java.lang.Boolean


public final class Boolean implements Serializable, Comparable<Boolean> {
// Public Constructors
     public Boolean(String s);  
     public Boolean(boolean value);  
// Public Constants
     public static final Boolean FALSE;  
     public static final Boolean TRUE;  
1.1  public static final Class<Boolean> TYPE;  
// Public Class Methods
     public static boolean getBoolean(String name);  
5.0  public static boolean parseBoolean(String s);  
1.4  public static String toString(boolean b);  
1.4  public static Boolean valueOf(boolean b);  
     public static Boolean valueOf(String s);  
// Public Instance Methods
     public boolean booleanValue( );  
// Methods Implementing Comparable
5.0  public int compareTo(Boolean b);  
// Public Methods Overriding Object
     public boolean equals(Object obj);  
     public int hashCode( );  
     public String toString( );  
}

    Team LiB
    Previous Section Next Section