Java Integer Create toInt(boolean flag)

Here you can find the source of toInt(boolean flag)

Description

This method is equivalent to flag ?

License

Open Source License

Parameter

Parameter Description
flag The <code>boolean</code> to be converted to an <code>int</code>

Return

the value 1 if true is passed, otherwise -1.

Declaration

public static int toInt(boolean flag) 

Method Source Code

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

public class Main {
    /**/*from w  ww .  j  av  a2 s.  c  o  m*/
     * This method is equivalent to <code>flag ? 1 : -1</code>.
     *
     * @param flag The <code>boolean</code> to be converted to an <code>int</code>
     *
     * @return the value 1 if <code>true</code> is passed, otherwise -1.
     */
    public static int toInt(boolean flag) {
        return flag ? 1 : -1;
    }
}

Related

  1. toInt(boolean value)
  2. toInt(boolean[] bits)
  3. toInt(byte b)
  4. toInt(byte b1, byte b2, byte b3, byte b4)