Java Integer Create toInt(String input, int defaultValue)

Here you can find the source of toInt(String input, int defaultValue)

Description

to Int

License

Apache License

Declaration

public static int toInt(String input, int defaultValue) 

Method Source Code

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

public class Main {
    public static int toInt(String input, int defaultValue) {
        try {/*from   www.j a va 2 s . c om*/
            return Integer.parseInt(input);
        } catch (Exception e) {
            return defaultValue;
        }
    }

    public static int toInt(String input, int radix, int defaultValue) {
        try {
            return Integer.parseInt(input, radix);
        } catch (Exception e) {
            return defaultValue;
        }
    }
}

Related

  1. toInt(short s0, short s1)
  2. toInt(short x, short y)
  3. toInt(short[] arr)
  4. toInt(String arr, String separator)
  5. toInt(String chars)
  6. toInt(String input, int offset, int length)
  7. toInt(String intValue, int defaultValue)
  8. toInt(String number)
  9. toInt(String numStr, int defaultValue)