Java Boolean Convert to boolToNum(Boolean bool)

Here you can find the source of boolToNum(Boolean bool)

Description

Converts a Boolean value to int value

License

Open Source License

Parameter

Parameter Description
bool Boolean value which needs to be converted to int value

Return

int value correspoding to the boolean : 1 for true and 0 for false

Declaration

public static int boolToNum(Boolean bool) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from w ww. ja v  a  2 s  .  c om
     * Converts a Boolean value to int value<br>
     * 
     * @param bool
     *            Boolean value which needs to be converted to int value
     * @return int value correspoding to the boolean : 1 for true and 0 for
     *         false
     */
    public static int boolToNum(Boolean bool) {
        int num = 0;
        if (bool.booleanValue()) {
            num = 1;
        }
        return num;
    }
}

Related

  1. booleanToDouble(boolean b)
  2. booleanToStr(boolean bool)
  3. booleanToTinyInt(boolean b)
  4. booleanToYesNo(Boolean b)
  5. BoolToNum(boolean bool)
  6. boolToNumber(boolean aBoolean)
  7. boolToYesNo(boolean b)