• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why Java didnt have mulitple inheritence via extending class

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Also... please search the forums, as this question comes up often.

Henry
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic