Why Java does not support multiple inheritance

Source: Internet
Author: User

Original link: http://javapapers.com/core-java/why-multiple-inheritance-is-not-supported-in-java/
Specific content can look at the above article, the following is just summed up a few points:
James Gosling, the father of 1:java, gave a white paper in 1995 on why multiple inheritance was not supported. “ JAVA omits many rarely used, poorly understood, confusing features of C + +, experience bring more grief than Bene?t. This primarily consists of operator overloading (although it does has method overloading), Multiple Inheritance , and extensive automatic coercions.
Basically, Gosling that multi-inheritance is a feature that is rarely used and easily confused, so the Java language removes multiple inheritance as if it were an operator overloading feature.
2:java is a way to realize multiple inheritance through the interface, which is debatable. This paragraph, the original author of the confusion, his main point is that the interface is to add attributes or behavior to the object, and inheritance refers to the full freedom from the parent class to obtain the implementation.
3: Multiple inheritance, the author has an image of the picture motioned, as below,The Pegasus (the Winged god horse, the place where its feet tread on the spring, the poet drink is inspired) is a classic multi-inheritance, inheriting the horse's body, as well as the Eagle's wings.
4. The author concludes, then, that why multiple inheritance is not supported is a design-based consideration for Java creators, mainly two points: language to be easy to use, and to discard some features that are rarely used and prone to confusion.
Two examples: Diamond problem (Diamond inheritance problem), almost no one has encountered the need to inherit more scenes, even if there is, can also be designed to bypass.


To be sure, the author of this blog is a source of speculation in some of the Java Founders ' literature and, of course, two examples. Although the logic is confusing, but very good is already point out the reason: multi-inheritance is a very little use is also very easy to confuse the language features, in the very few need to use the scene, but also through the design to bypass (like the Pegasus above, Java is generally the flying wings as an interface). So in order to maintain the ease of use of the language, Java design at the beginning of the rejection of this feature.

Why Java does not support multiple inheritance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.