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
Simply use method overloading.
public void utterlyDestroy(Dreams parameter) { parameter.crush(); } public void utterlyDestroy(Garlic parameter) { parameter.crush(); }
If you want to support more than these two types in the same way, you can define a common interface for them all and use generics.