If a method takes an Object parameter, can this parameter be type casted by
any class?
Example:
public int compareTo(Object o) {
Name n = (Name) o;
}
public int MultiplyPrint(Object o) {
String testString = (String) o;
Int num = Integer.parseInt(testString);
int theResult = Math.pow(num,2);
return theResult;
}
public Orange Apple2Orange(Object o) {
Apple apple = (Apple) o;
// Convert to Orange
Orange orange = (Orange) apple;
return Orange;
}
Also, is it poor programming style to rely on type casting?
TIA
James Davis