public static int convertObjectToInt(Object obj) { if (obj.getClass().toString().contains("Integer")) { return (Integer) obj; } if (obj.getClass().toString().contains("String")) { return convertStringToInt((String) obj); } Ts.printErr("error on converting to integer"); //----- it never be reached return -1; } public static int convertStringToInt(String str) { return Integer.parseInt(str); } public static void printErr(String str) { System.out.println("---> error : " + str); System.exit(-1); }