We can use the Boolean wrapper class for converting a primitive boolean value to an object.
public class BooleanWrapper {
public static void main(String args[]) {
boolean bool = true;
Boolean objBool = Boolean.valueOf(bool);
System.out.println(objBool);
}
}
or
public class BooleanWrapper {
public static void main(String[] args) {
boolean bool = true;
Boolean objBool = new Boolean(bool);
System.out.println(objBool);
}
}
The first method would perform better. So it is the recommended way of creating a wrapper class for primitive boolean type.




















