Boolean Class

Boolean class wraps value of boolean data type in an object. If we want to pass boolean variable in a method which require object then we need to make Boolean class object then we pass that object.


  Boolean(boolean b) 
Boolean(String s)

Boolean class has two type of constructor one take boolean value and another take String representation of boolean value.

Creating Boolean class object

 Boolean b=new Boolean(true);// by using first constructor 
Boolean c=new Boolean("false");// by using second constructor

Methods of Boolean Class

Method Description
static Boolean valueOf(String s) Returns a Boolean object with value represented by specified string.
static Boolean valueOf(boolean b) Returns a Boolean object with value specified by variable b.
boolean booleanValue() Returns the value of Boolean this object in form of primitive data type boolean.
int compareTo(Boolean c) Compare two Boolean object numerically.
boolean equals(Object ob) Compare this object against specified object.
static String toString(boolean b) Return a String object representing value b.
String toString() Return a String object representing this object's value.