my dog learned polymorphism
The moose likes Java in General and the fly likes why we can't inharit more than one class ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "why we can Watch "why we can New topic
Author

why we can't inharit more than one class ?

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 744
why we can't inharit more than one class ???


Jigar Naik


Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12911
    
    3

Having more than one base class is called multiple inheritance. C++ supports this, Java does not.

In practice, you never really need multiple inheritance, and it leads to dilemmas like the Diamond problem.

The designers of the Java language decided that multiple inheritance wasn't needed and that it only would make the language unnecessarily complicated, so they left it out.
[ May 17, 2007: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32654
    
    4
As Jesper Young said, because the designers of Java thought it made things too complicated. Whoever designs a language has to make such decisions.
I found a paper yesterday [Martin P (1998): Java, the good, the bad and the ugly ACM SIGPLAN Notices archive 33: 34 - 39] which says the multiple inheritance model in C++ is poor and Eiffel has a better model.
Ricky Clarkson
Ranch Hand

Joined: Jul 27, 2006
Posts: 131
In my opinion, single inheritance is one too many. There are better forms of code reuse.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: why we can't inharit more than one class ?
 
Similar Threads
Extending interface
How do we define atmost one public class in our application
How many object can a class have?
Why only one public class per file??
CAn someone please explain this statement.