Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Multiple Inheritance
Posted by Darryl Morgan on November 09, 2000 at 6:39 PM
> > I have library of some classes. > > Now I want to create one class, which extends three classes from library. > > Say in library there are class A, B and C. > > I want to create class D which extends A,B and C. > > How can I do that? > > Is it possible? > > Thank you very much in advance. > > Regards, > > Dinesh > No ,you cannot extend from multiple classes .In Java ,multiple inheritance is supported thru Interfaces.So ,if possible,create A,B,C as interfaces and then let class D implement them. > Ira Yes, that is correct but the only issue is that D has to implement the behaviour which might also be common in say class F wishes to extend A,B,C and a new class E. There are some design patterns which overcome this issue that you've come across. The delegate and container patterns are some that have been suggested. I'm still reading up on the possible solutions as I too face the same problem.
Darryl Morgan
Replies:
|