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

ruby on rails - Devise Logout Error in RoR -

model view controller - MVC Rails Planning -

php - Working with pretty urls on apache and fastcgi after hhvm installation -