Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Java by (10.2k points)
What is the most accepted way to convert a boolean to an int in Java?

1 Answer

0 votes
by (46k points)

Try:

int myInt = myBoolean ? 1 : 0;

If true = 1 and if false = 0

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...