Revision as of 04:26, 23 November 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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);
}


Back to JavaHowTo

Alumni Liaison

Sees the importance of signal filtering in medical imaging

Dhruv Lamba, BSEE2010