introduction
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.
class declaration
following is the declaration for java.lang.boolean class −
public final class boolean
extends object
implements serializable, comparable<boolean>
field
following are the fields for java.lang.boolean class −
static boolean false − this is the boolean object corresponding to the primitive value false.
static boolean true − this is the boolean object corresponding to the primitive value true.
static class<boolean> type − this is the class object representing the primitive type boolean.
class constructors
| sr.no. | constructor & description |
|---|---|
| 1 |
boolean(boolean value) this allocates a boolean object representing the value argument. |
| 2 |
boolean(string s) this allocates a boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true". |
class methods
| sr.no. | method & description |
|---|---|
| 1 |
boolean booleanvalue()
this method returns the value of this boolean object as a boolean primitive. |
| 2 |
int compareto(boolean b)
this method compares this boolean instance with another. |
| 3 |
boolean equals(object obj)
this method 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. |
| 4 |
static boolean getboolean(string name)
this method returns true if and only if the system property named by the argument exists and is equal to the string "true". |
| 5 |
int hashcode()
this method returns a hash code for this boolean object. |
| 6 |
static boolean parseboolean(string s)
this method parses the string argument as a boolean. |
| 7 |
string tostring()
this method returns a string object representing this boolean's value. |
| 8 |
static string tostring(boolean b)
this method returns a string object representing the specified boolean. |
| 9 |
static boolean valueof(boolean b)
this method returns a boolean instance representing the specified boolean value. |
| 10 |
static boolean valueof(string s)
this method returns a boolean with a value represented by the specified string. |
methods inherited
this class inherits methods from the following classes −
- java.lang.object