1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
/* Convert boolean to Boolean object Example This example shows how a java boolean primitive can be converted to a Boolean object. */ public class BooleanPrimitiveToBooleanObjectExample { public static void main(String[] args) { boolean b = true; //1. using constructor Boolean blnObj1 = new Boolean(b); //2. using valueOf method of Boolean class. This is a static method. Boolean blnObj2 = Boolean.valueOf(b); } } /* Output would be : true true */ |
Add Comment