Multiple Inheritance in java

前端 未结 8 1446
無奈伤痛
無奈伤痛 2020-11-27 21:27

Java is not allowing inheritance from multiple classes (still it allows inheritance from multiple interfaces.), I know it is very much inline with classic diamond problem. B

8条回答
  •  伪装坚强ぢ
    2020-11-27 21:57

    I have read that most programmers don't use multiple inheritance in a proper way. "Just go ahead and inherit from a class just to reuse code" is not the best practice in case of multiple inheritance.

    Many programmers do not know when to use simple inheritance in most cases. Multiple inheritance must be used with caution and only if you know what you are doing if you want to have a good design.

    I don't think that the lack of multiple inheritance in java (as in c++) will put restrictions in your code / application design / problem domain mapping into classes.

提交回复
热议问题