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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -