Java Digit From toDigit(final boolean bit)

Here you can find the source of toDigit(final boolean bit)

Description

Converts a boolean into a digit.

License

Open Source License

Parameter

Parameter Description
bit the boolean to interpret

Return

1, if bit was true, 0 otherwise

Declaration

public static int toDigit(final boolean bit) 

Method Source Code

//package com.java2s;

public class Main {
    private static final int TRUE = 1;
    private static final int FALSE = 0;

    /**//from  w ww  .j a va2 s  . c o m
     * Converts a boolean into a digit.
     * 
     * @param bit
     *            the boolean to interpret
     * @return 1, if bit was <code>true</code>, 0 otherwise
     */
    public static int toDigit(final boolean bit) {
        return (bit) ? TRUE : FALSE;
    }
}

Related

  1. toDigit(char c)
  2. toDigit(char ch)
  3. toDigit(char ch, int index)
  4. toDigit(final char ch, final int index)
  5. toDigit(final char ch, final int index)
  6. toDigit(final int value)
  7. toDigit(int c)