Here you can find the source of toInt(String str, int defaultValue)
Parameter | Description |
---|---|
value | a parameter |
defaultValue | a parameter |
public static final int toInt(String str, int defaultValue)
//package com.java2s; //License from project: Apache License public class Main { /**// ww w . j av a 2 s . com * Convert the string to int. * @param value * @param defaultValue * @return */ public static final int toInt(String str, int defaultValue) { int value = defaultValue; if (str == null || str.length() <= 0) { return value; } try { value = Integer.parseInt(str); } catch (NumberFormatException e) { value = defaultValue; } return value; } }