Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to get functionality fo two different classes in one

 
Yuvarajan M
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic