int myInt = myBoolean ? 1 : 0;
^^
PS : true = 1 and false = 0
More Related Contents:
- How are integers cast to bytes in Java?
- How do I convert from int to Long in Java?
- Java > Generate a lot of int
- Why don’t Java’s +=, -=, *=, /= compound assignment operators require casting?
- Downcasting in Java
- The literal xyz of type int is out of range
- What is the size of a boolean variable in Java?
- Why is Java’s boolean primitive size not defined?
- Does Java casting introduce overhead? Why?
- Why can not I add two bytes and get an int and I can add two final bytes get a byte?
- Cast Double to Integer in Java
- How to convert float to int with Java
- “int cannot be dereferenced” in Java
- Why do we assign a parent reference to the child object in Java?
- Java, Simplified check if int array contains int
- Java Round up Any Number
- Dealing with an ArrayStoreException
- How does the Java cast operator work?
- In Java, what are the boolean “order of operations”?
- How to cast an Object to an int
- Cleanest way to toggle a boolean variable in Java?
- Effect of a Bitwise Operator on a Boolean in Java
- How to have Java method return generic list of any type?
- Casting an array of Objects into an array of my intended class
- Return first digit of an integer
- Casting to generic type in Java doesn’t raise ClassCastException?
- Java – Change int to ascii
- Why boolean in Java takes only true or false? Why not 1 or 0 also?
- Unexpected result in long/int division
- Valid JavaBeans names for boolean getter methods