Here you can find the source of parseInt(Object str)
public static Integer parseInt(Object str)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static Integer parseInt(Object str) { return str == null ? 0 : Integer.valueOf((isNumeric(str.toString())) ? Integer.parseInt(str.toString()) : 0); }//ww w . j av a 2 s. c o m public static boolean isNumeric(String str) { Matcher isNum = Pattern.compile("(-|\\+)?[0-9]+(.[0-9]+\\+)?").matcher(str); return isNum.matches(); } }