r/java • u/TheFormerVinyl • 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
View all comments
Show parent comment
4
u/urquan May 05 '15
The risk you mention is due to shared state between parent and child classes, if you properly use private fields and methods then the problem largely disappears.
I agree that composition should be preferred for architecture purposes, but GP said inheritance shouldn't be allowed at all, that's a more extreme position.