Java - Why multiple inheritances are not supported in Java
来源:互联网 发布:酒店订房系统 php源码 编辑:程序博客网 时间:2024/05/16 19:28
http://javarevisited.blogspot.de/2011/07/why-multiple-inheritances-are-not.html
Sometimes I can't open this page without proper proxy, so I have to copy the content here.
1) First reason is ambiguity around Diamond problem. Consider a class A has foo() method and then B and C derived from A and has their own foo() implementation and now class D derive from B and C using multiple inheritance. And if we refer just foo(), compiler will not be able to decide which foo() it should invoke. This is also called Diamond problem because structure on this inheritance scenario is similar to 4 edge diamond, see below
A foo()
/ \
/ \
foo() B C foo()
\ /
\ /
D
foo()
2) Second and more convincing reason to me is that multiple inheritances does complicate the design and creates problem during casting, constructor chaining etc. 没有多少场景需要多重继承。 可以通过实现Interface来间接实现多重继承。
- Java - Why multiple inheritances are not supported in Java
- Why multiple inheritances are not supported in Java
- Why Multiple Inheritance is Not Supported in Java
- Why Enum Singleton are better in Java
- Why most large-scale Web sites are not written in Java
- Java - Why Enum Singleton are better in Java
- multiple input paths are not supported for libsvm data
- Annotations are not supported in -source 1.3 – Maven
- Maven错误generics are not supported in -source 1.3
- Why is VS development not supported with multiple versions of Office?
- Why is VS development not supported with multiple versions of Office
- Why are MVC & TDD not employed more in game architecture?
- java 8 不能兼容 instant run 解决方法记录 lambda expression are not supported at this laungh level
- jenkins报错strings in switch are not supported in -source 1.5
- Why Are Some OSPF Routes in the Database but Not in the Routing Table?
- java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
- java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
- java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
- PAT简单题目代码
- 吞吐量(Throughput)、QPS、并发数、响应时间(RT)对系统性能的影响
- PHP 静态变量和静态方法
- nsstring to nsdata
- AFNetWorking基本使用
- Java - Why multiple inheritances are not supported in Java
- iOS 摇一摇
- Guice 学习(七)常量和属性的注入( Constant and Property Inject)
- IOS: 应用截图尺寸和启动图片
- Hibernate POJO为什么要实现Serializable接口
- Tomat之——多项目jar包共享配置
- 【Github教程】史上最全github使用方法:github入门到精通
- 算法---行列递增矩阵的查找
- 实时调度算法可分为固定优先级的调度算法和动态优先级的调度算法