Why is there no multiple inheritance in Java, but implementing multiple interfaces is allowed?

后端 未结 18 2045
囚心锁ツ
囚心锁ツ 2020-11-22 14:55

Java doesn\'t allow multiple inheritance, but it allows implementing multiple interfaces. Why?

18条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 15:29

    Because inheritance is overused even when you can't say "hey, that method looks useful, I'll extend that class as well".

    public class MyGodClass extends AppDomainObject, HttpServlet, MouseAdapter, 
                 AbstractTableModel, AbstractListModel, AbstractList, AbstractMap, ...
    

提交回复
热议问题