Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static int doInt(Object obj) { return obj != null ? Integer.parseInt(obj.toString()) : 0; } public static int doInt(Object obj, int defValue) { return obj != null ? Integer.parseInt(obj.toString()) : defValue; } }