What is the most accepted way to convert a boolean
to an int
in Java?
Advertisement
Answer
JavaScript
x
int myInt = myBoolean ? 1 : 0;
^^
PS : true = 1 and false = 0
What is the most accepted way to convert a boolean
to an int
in Java?
int myInt = myBoolean ? 1 : 0;
^^
PS : true = 1 and false = 0