Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int myInt = myBoolean ? 1 : 0;
- int val = b? 1 : 0;
- int boolToInt(Boolean b) {
- return b.compareTo(false);
- }
- int boolToInt(boolean b) {
- return Boolean.compare(b, false);
- }
- boolean b = ....;
- int i = -("false".indexOf("" + b));
- public int boolToInt(boolean b) {
- return b ? 1 : 0;
- }
- if (something) {
- otherThing = 1;
- } else {
- otherThing = 0;
- }
- int otherThing = something ? 1 : 0;
- Process process = Process.SYNCHRONOUS;
- System.out.println(process.getCode());
- public enum Process {
- SYNCHRONOUS (0),
- ASYNCHRONOUS (1);
- private int code;
- private Process (int code) {
- this.code = code;
- }
- public int getCode() {
- return code;
- }
- }
- import org.apache.commons.lang3.BooleanUtils;
- boolean x = true;
- int y= BooleanUtils.toInteger(x);
- boolean b = true;
- int i = b ? 1 : 0; // assigns 1 to i.
- int myInt = BooleanUtils.toInteger(boolean_expression);
- System.out.println( 1 & Boolean.hashCode( true ) >> 1 ); // 1
- System.out.println( 1 & Boolean.hashCode( false ) >> 1 ); // 0
- public int valueOf(Boolean flag) {
- return Boolean.compare(flag, Boolean.TRUE) + 1;
- }
- public static int convBool(boolean b)
- {
- int convBool = 0;
- if(b) convBool = 1;
- return convBool;
- }
- MyClass.convBool(aBool);
Add Comment
Please, Sign In to add comment