hpique hpique - 5 months ago 11
Java Question

Convert boolean to int in Java

What is the most accepted way to convert a

boolean
to an
int
in Java?

Answer
int myInt = (myBoolean) ? 1 : 0;

^^

PS : true = 1 and false = 0

Comments