daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int myInt = myBoolean ? 1 : 0;
  2.    
  3. int val = b? 1 : 0;
  4.    
  5. int boolToInt(Boolean b) {
  6.     return b.compareTo(false);
  7. }
  8.    
  9. int boolToInt(boolean b) {
  10.     return Boolean.compare(b, false);
  11. }
  12.    
  13. boolean b = ....;
  14. int i = -("false".indexOf("" + b));
  15.    
  16. public int boolToInt(boolean b) {
  17.     return b ? 1 : 0;
  18. }
  19.    
  20. if (something) {
  21.     otherThing = 1;
  22. } else {
  23.     otherThing = 0;
  24. }
  25.    
  26. int otherThing = something ? 1 : 0;
  27.    
  28. Process process = Process.SYNCHRONOUS;
  29. System.out.println(process.getCode());
  30.    
  31. public enum Process {
  32.  
  33.     SYNCHRONOUS (0),
  34.     ASYNCHRONOUS (1);
  35.  
  36.     private int code;
  37.     private Process (int code) {
  38.         this.code = code;
  39.     }
  40.  
  41.     public int getCode() {
  42.         return code;
  43.     }
  44. }
  45.    
  46. import org.apache.commons.lang3.BooleanUtils;
  47. boolean x = true;  
  48. int y= BooleanUtils.toInteger(x);
  49.    
  50. boolean b = true;
  51. int i = b ? 1 : 0; // assigns 1 to i.
  52.    
  53. int myInt = BooleanUtils.toInteger(boolean_expression);
  54.    
  55. System.out.println( 1 & Boolean.hashCode( true ) >> 1 );  // 1
  56. System.out.println( 1 & Boolean.hashCode( false ) >> 1 ); // 0
  57.    
  58. public int valueOf(Boolean flag) {
  59.    return Boolean.compare(flag, Boolean.TRUE) + 1;
  60. }
  61.    
  62. public static int convBool(boolean b)
  63. {
  64. int convBool = 0;
  65. if(b) convBool = 1;
  66. return convBool;
  67. }
  68.    
  69. MyClass.convBool(aBool);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top