I very well know that it can be done with the help of interfaces and i have done it many times. But this time my situation is quite difference. I have class A
,
You may try create class C
that will contain one instance of class A
and one of class B
and their methods (create methods with same names that will just call methods from A
and B
), it's called Composition - another method in opposite to inheritance. Of course that's in case if you don't need instanceof
to work with that C
class.