Java Integer Parse tryParseInt(String value)

Here you can find the source of tryParseInt(String value)

Description

try Parse Int

License

Apache License

Declaration

public static int tryParseInt(String value) 

Method Source Code

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

public class Main {

    public static int tryParseInt(String value) {
        try {// www.  j a v  a  2  s  .  c om
            return Integer.parseInt(value);
        } catch (Exception e) {
            return -1;
        }
    }

    public static int tryParseInt(String value, int defaultValue) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {
            return defaultValue;
        }
    }
}

Related

  1. tryParseInt(String str)
  2. tryParseInt(String str, int defaultValue)
  3. tryParseInt(String stringInt)
  4. tryParseInt(String text)
  5. tryParseInt(String value)
  6. tryParseInteger(String intValue)
  7. tryParseInteger(String text)
  8. TryParseIntInvariant(String str, int[] n)
  9. tryParseInts(String[] in)