| Author |
Why Java didnt have mulitple inheritence via extending class
|
MaheshS Kumbhar
Ranch Hand
Joined: Sep 24, 2009
Posts: 188
|
|
I was just jumbled upon one question and to be curious, I would like to know, why Java didn't allow multiple inheritence via extending classes and why it did implement it via interface technique?
Thanks in advance.
|
I am slow but sure
|
 |
Bobby Smallman
Ranch Hand
Joined: Sep 09, 2010
Posts: 107
|
|
Extending multiple classes was primarily left out in order to keep Java "simple." The main problem which programmers could encounter with being able to extend multiple classes is the Diamond Problem (which I prefer to call the Dastardly Diamond of Death) When extending multiple classes it creates a serious possibility of ambiguity in your method calls/classes. The reason why multiple interfaces are allowed to be implemented is that you must override all methods provided by the interfaces you are implementing. While you can still have odd naming problems with multiple interfaces the forced override of all methods in the implementing class helps to limit all the pitfalls of extending multiple classes.
There was an old entertaining article about interfaces and why Java developers decided to go the route the did, I will edit my post if I come across it again.
|
Everyday in every way, we get a little better.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
Also... please search the forums, as this question comes up often.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: Why Java didnt have mulitple inheritence via extending class
|
|
|