I am writing a method that should accept as its parameter an object of one of two types which do not share a parent type other than Object. For example, the types are Dreams
As I'm using :
void fooFunction(Object o){ Type1 foo=null; if(o instanceof Type1) foo=(Type1)o; if(o instanceof Type2) foo=((Type2)o).toType1(); // code }
But that only works if Type2 can be converted to Type1