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