Class Boolean

java.lang.Object
java.lang.Boolean
All Implemented Interfaces:
Comparable<Boolean>

public final class Boolean extends Object implements Comparable<Boolean>
The Boolean 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. Since: JDK1.0, CLDC 1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Boolean
    The Boolean object corresponding to the primitive value false.
    static final Boolean
    The Boolean object corresponding to the primitive value true.
    static final Class<Boolean>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Boolean(boolean value)
    Allocates a Boolean object representing the value argument.
    Deprecated.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of this Boolean object as a boolean primitive.
    static int
    compare(boolean x, boolean y)
    0 when equal, otherwise positive when x is true.
    int
    Compares this object to the specified object to determine their relative order.
    boolean
    Returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.
    static boolean
    Whether the system property name is "true", ignoring case.
    int
    Returns a hash code for this Boolean object.
    static int
    hashCode(boolean value)
    1231 for true, 1237 for false, as the JDK hashes them.
    static boolean
    logicalAnd(boolean a, boolean b)
    a && b.
    static boolean
    logicalOr(boolean a, boolean b)
    a || b.
    static boolean
    logicalXor(boolean a, boolean b)
    a ^ b.
    static boolean
     
    Returns a String object representing this Boolean's value.
    static String
    toString(boolean b)
    "true" or "false".
    static Boolean
    valueOf(boolean b)
    Returns the object instance of i
    static Boolean
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • FALSE

      public static final Boolean FALSE
      The Boolean object corresponding to the primitive value false.
    • TRUE

      public static final Boolean TRUE
      The Boolean object corresponding to the primitive value true.
    • TYPE

      public static final Class<Boolean> TYPE
  • Constructor Details

    • Boolean

      public Boolean(boolean value)
      Allocates a Boolean object representing the value argument. value - the value of the Boolean.
    • Boolean

      @Deprecated public Boolean(String s)
      Deprecated.
      A Boolean of parseBoolean(s).
  • Method Details

    • booleanValue

      public boolean booleanValue()
      Returns the value of this Boolean object as a boolean primitive.
    • equals

      public boolean equals(Object obj)
      Returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash code for this Boolean object.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a String object representing this Boolean's value. If this object represents the value true, a string equal to "true" is returned. Otherwise, a string equal to "false" is returned.
      Overrides:
      toString in class Object
    • valueOf

      public static Boolean valueOf(boolean b)

      Returns the object instance of i

      Parameters
      • b: the primitive
      Returns

      object instance

    • valueOf

      public static Boolean valueOf(String b)
    • parseBoolean

      public static boolean parseBoolean(String s)
    • compareTo

      public int compareTo(Boolean b2)
      Description copied from interface: Comparable

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

      Parameters
      • another: the object to compare to this instance.
      Returns
      Specified by:
      compareTo in interface Comparable<Boolean>
      Returns:

      a negative integer if this instance is less than another; a positive integer if this instance is greater than another; 0 if this instance has the same order as another.

      Throws
      • ClassCastException: @throws ClassCastException if another cannot be converted into something comparable to this instance.
    • toString

      public static String toString(boolean b)
      "true" or "false".
    • hashCode

      public static int hashCode(boolean value)
      1231 for true, 1237 for false, as the JDK hashes them.
    • compare

      public static int compare(boolean x, boolean y)
      0 when equal, otherwise positive when x is true.
    • logicalAnd

      public static boolean logicalAnd(boolean a, boolean b)
      a && b.
    • logicalOr

      public static boolean logicalOr(boolean a, boolean b)
      a || b.
    • logicalXor

      public static boolean logicalXor(boolean a, boolean b)
      a ^ b.
    • getBoolean

      public static boolean getBoolean(String name)
      Whether the system property name is "true", ignoring case.