Java Integer Create toInt(Number num)

Here you can find the source of toInt(Number num)

Description

to Int

License

Apache License

Declaration

public static int toInt(Number num) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static int toInt(Number num) {
        if (num == null) {
            return 0;
        } else {/*from  w  ww  . j  a v a 2  s  .  c  om*/
            return num.intValue();
        }
    }

    public static int toInt(Number num, int defaultValue) {
        if (num == null) {
            return defaultValue;
        } else {
            return num.intValue();
        }
    }

    public static int toInt(boolean flag) {
        return flag ? 1 : 0;
    }

    // @Deprecated
    public static int toInt(Object num) {
        if (num == null) {
            return 0;
        } else {
            return Integer.parseInt(num.toString());
        }
    }
}

Related

  1. toInt(Integer n)
  2. toInt(long l)
  3. toInt(long l)
  4. toInt(long unsignedInt)
  5. toInt(long[] a)
  6. toInt(Number value)
  7. toInt(Number wrapped)
  8. toInt(Object bean, int defaultValue)
  9. toInt(Object num)