Can I convert boolean into another data type in Java -
Can I convert boolean into another data type in Java -
i have next code:
public class myfirstjavaprogram {         public static void main(string []args) {            boolean b = true;            int x = b;            system.out.println(x);     } }     as title say, can convert boolean type   info type (in above example, char), using java?
no cannot.
if looking one-line solution set int, can  utilize ternary operation, such:
int x = b ? 1 : 0;        java type-conversion 
 
Comments
Post a Comment