Java String to Int asInt(String str, int defaultValue)

Here you can find the source of asInt(String str, int defaultValue)

Description

as Int

License

Apache License

Declaration

public static int asInt(String str, int defaultValue) 

Method Source Code

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

public class Main {
    public static int asInt(String str, int defaultValue) {
        try {//from  w w  w. j  a va 2  s.  c  o m
            return Integer.parseInt(str);
        } catch (Exception e) {
            return defaultValue;
        }
    }
}

Related

  1. asInt(String number)
  2. asInt(String str)
  3. asInt(String str)
  4. asInt(String sval, int dflt)
  5. asInt(String value)
  6. asInteger(String param)
  7. asInteger(String string)