java中的多重继承 [英] Multiple Inheritance in java

查看:129
本文介绍了java中的多重继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java不允许从多个类继承(仍允许从多个接口继承。),我知道它与经典钻石问题非常相似。但是我的问题是,为什么java在从多个基类继承时没有歧义(因此没有钻石问题的机会)时不允许像C ++这样的多重继承?

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. But my questions is why java is not allowing multiple inheritance like C++ when there is no ambiguity (and hence no chances of diamond problem) while inheriting from multiple base class ?

推荐答案

这是一个设计Java的决定。你永远不会得到它,所以不要太担心它。尽管MI可能会帮助你制作Mixins,但这是唯一能帮助你的MI。

It was a design decision of Java. You'll never get it, so don't worry too much about it. Although MI might help you make Mixins, that's the only good MI will ever do you.

这篇关于java中的多重继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆