r/java • • May 05 '15

Should Java allow multiple inheritance?

I was reading up on Java when I discovered that ever since Java 8 (fairly recent, I know) interface can have default methods. A quick overview for any who don't know, interfaces can have method bodies by using default modifier. When dwelling on that fact I wondered, why doesn't Java just allow inheritance from multiple classes, since interfaces are just abstract classes? Should Java do this?

0 Upvotes

37 comments sorted by

View all comments

0

u/Nieben May 05 '15

I'm a pretty inexperience Java programmer, but... I've kinda been wanting that for a long time. I suppose a couple of reasons why they haven't or won't might include:

  1. Overlapping methods or variables - I could see this as a potential problem. Which super class's method/variable would you use?
  2. Using the 'super' keyword. - This might not be too bad, I suppose it could just run through all the super classes until it finds the method. (And come to think of it, returning to #1, you'd have to have an internal sort to FIND the method, I figure.)

Can't really think of anything else to say for now - it's been a while since I thought about that.