Originally posted by Paul Clapham:
I see that Class has an isInstance() method
Thanks, that is clearly the tool to build what I need. What I'm looking for is roughly a lowest common superclass. Sure, everything is at the top an Object.
What I'm looking for is the lowest common class that the two objects share.
Consider a
Fruit class, and many subclasses,
class Berry extends Fruit
Naturally, in the real implementation, there are many levels of inheritance.
then you have code like:
You want to be able to getCommonSuper(f1, f2) and get Fruit, while
getCommonSuper(f1, f3) is Berry