Login
Remember
Register
Questions
Unanswered
Ask a Question
Blog
Tutorials
Interview Questions
Ask a Question
community
Java
Convert boolean to int in Java
Convert boolean to int in Java
0
votes
1
view
asked
Aug 6, 2019
in
Java
by
Anvi
(
10.2k
points)
What is the most accepted way to convert a boolean to an int in Java?
java
casting
java-faq
boolean
int
Please
log in
or
register
to add a comment.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
1
Answer
0
votes
answered
Aug 6, 2019
by
Ayush
(
46.1k
points)
Try:
int myInt = myBoolean ? 1 : 0;
If true = 1 and if false = 0
Please
log in
or
register
to add a comment.
Related questions
0
votes
1
answer
How to convert float to int with Java
asked
Aug 6, 2019
in
Java
by
Krishna
(
2.6k
points)
java
int
floating-point
java-faq
0
votes
1
answer
How can I convert String object to Boolean Object?
asked
Aug 8, 2019
in
Java
by
Suresh
(
3.4k
points)
java
string
java-faq
boolean
0
votes
1
answer
Java int to String - Integer.toString(i) vs new Integer(i).toString()
asked
Jul 18, 2019
in
Java
by
Shubham
(
3.9k
points)
java
int
string
java-faq
0
votes
1
answer
Cast Int to enum in Java
asked
Aug 7, 2019
in
Java
by
Nigam
(
4.1k
points)
java
enums
ordinal
java-faq
casting
0
votes
1
answer
Safely casting long to int in Java
asked
Jul 15, 2019
in
Java
by
Nigam
(
4.1k
points)
java
java-faq
casting
Welcome to Intellipaat Community. Get your technical queries answered by top developers !
Categories
All categories
Python
(2.8k)
Java
(1.2k)
SQL
(1.3k)
Linux
(209)
Big Data Hadoop & Spark
(1.1k)
Data Science
(2.4k)
R Programming
(837)
C Programming
(14)
Devops and Agile
(2.7k)
Docker
(48)
AI and Deep Learning
(1.3k)
Machine Learning
(1k)
AWS
(2.2k)
Azure
(1.3k)
GCP
(198)
RPA
(597)
Selenium
(153)
Blockchain
(405)
Salesforce
(697)
Others
(50)
BI
(1.5k)
IoT
(24)
Web Technology
(1.2k)
Cyber Security
(241)
Digital Marketing
(149)
Technology Trends
(44)
SEO
(104)
Informatica
(13)
...