wood burning stoves 2.0*
The moose likes Java in General and the fly likes Need to get functionality fo two different classes in one Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need to get functionality fo two different classes in one" Watch "Need to get functionality fo two different classes in one" New topic
Author

Need to get functionality fo two different classes in one

Yuvarajan M
Greenhorn

Joined: Jan 09, 2002
Posts: 1
Hi all,
I need inherit the functionality of two complete class into one. Is there a way to do this in??
with regards,
yuva
Maciej Kolodziej
Greenhorn

Joined: Feb 11, 2002
Posts: 26
I suppose You have thought about interfaces and it doesn't fit for You - You need to inherit from two implementations, not interfaces.
So the only way You can do that in Java is to use inner classes. It's not multiple inheritance, like in C++, but in most cases it should do. Inner class can manipulate the outer class object and each inner class can independently inherit from different implementation.
Hope it helps.


MK
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Are you SURE that you can't use composition to get the benefits of inheritance? Couldn't your class just have an instance of one of the other classes and use that instance to get at its methods?
Why don't you explain a bit about the classes and what you are trying to accomplish.
 
Consider Paul's rocket mass heater.
 
subject: Need to get functionality fo two different classes in one