Intellipaat 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
asked Oct 28, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Aug 7, 2019 in Java by Nigam (4k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...