java.lang.Boolean Class & Methods


The java.lang.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.  This class provides many 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.

Boolean class implements Comparable Interface that’s help while sorting list of Objects on natural order.

See Also:

Constants

  • static Boolean FALSE :The Boolean object corresponding to the primitive value false.
  • static Boolean TRUE :The Boolean object corresponding to the primitive value true.
  • static Class TYPE :The Class object representing the primitive type boolean.

Constructors

  • Boolean(boolean value) :Allocates a Boolean object representing the value argument.
    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”.

Methods

  • boolean booleanValue() :Returns the value of this Boolean object as a boolean primitive.
  • static int compare(boolean x, boolean y) :Compares two boolean values.
  • int compareTo(Boolean b) :Compares this Boolean instance with another.
  • 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.
  • static boolean getBoolean(String name) :Returns true if and only if the system property named by the argument exists and is equal to the string “true”.
  • int hashCode() :Returns a hash code for this Boolean object.
  • static boolean parseBoolean(String s) :Parses the string argument as a boolean.
  • String toString() :Returns a String object representing this Boolean’s value.
  • static String toString(boolean b) :Returns a String object representing the specified boolean.
  • static Boolean valueOf(boolean b) :Returns a Boolean instance representing the specified boolean value.
  • static Boolean valueOf(String s) :Returns a Boolean with a value represented by the specified string.

References

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s