Here you can find the source of toInt(String value, int defaultValue)
Parameter | Description |
---|---|
value | a parameter |
defaultValue | a parameter |
public static int toInt(String value, int defaultValue)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w. ja v a 2 s . c o m * tries to parse the given String into an integer * if this fails the default value is returned * @param value * @param defaultValue * @return */ public static int toInt(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException ex) { return defaultValue; } } }