Here you can find the source of toInt(Object obj)
public static int toInt(Object obj)
//package com.java2s; public class Main { public static int toInt(Object obj) { Integer i = toInteger(obj); if (i != null) { return i.intValue(); }//from w ww .j ava 2 s . c o m return 0; } public static Integer toInteger(Object obj) { if (obj != null) { if (obj instanceof Integer) { return (Integer) obj; } else { try { return Integer.parseInt(String.valueOf(obj)); } catch (Exception e) { } } } return null; } }