2. 2. 1. java.lang.Boolean |
|
The java.lang.Boolean class wraps a boolean.
You can construct a Boolean object from a boolean or a String, using one of these constructors. |
public Boolean (boolean value)
public Boolean (String value)
|
|
For example: |
Boolean b1 = new Boolean (false);
Boolean b2 = new Boolean ("true");
|
|
To convert a Boolean to a boolean, use its booleanValue method: public boolean booleanValue() |
public class MainClass {
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());
}
}
|
|
false
true |