Java Data Type How to - Convert a Boolean to a boolean, use its booleanValue method








Question

We would like to know how to convert a Boolean to a boolean, use its booleanValue method.

Answer

public class MainClass {
/*from   www  . j  a v a2  s  . com*/
  public static void main(String[] args) {
    Boolean b1 = new Boolean(false);
    Boolean b2 = new Boolean("true");

    System.out.println(b1.booleanValue());
    System.out.println(b2.booleanValue());
  }

}

The code above generates the following result.