-4

i tried to create a calc class which will have methords of mathematical operators which are not in java already..........

now after i created it ....if i wat to use this class functions i will have to make it a super class for my new program but .....if i want my new program to have multiple attributes of diffrent classes .........and simultaneously use calc functions........but i cant..............

why java doesnt have multiple inheritances.......what are its advantages and disadvantages?

tnx in advanced...

  • 1
    Edit your question by removing parts "why is Java designed the way it is" and ask about your specific problem you need to solve and add some code to make it more clear what you are doing. Java does not have multiple inheritance, but there are other ways to achieve your goals. Particularly with interfaces. – Dalija Prasnikar May 31 '15 at 11:50
  • In short: to avoid [diamond problem](http://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem). – Pshemo May 31 '15 at 11:56
  • Java 8 introduced [default methods](https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html) which seems to make multiple inheritance available in Java. – Seelenvirtuose May 31 '15 at 12:01
  • @Seelenvirtuose: it just seems that way. It's still not the same. – Stultuske May 31 '15 at 12:12
  • 1
    possible duplicate of [Why is Multiple Inheritance not allowed in Java or C#?](http://stackoverflow.com/questions/995255/why-is-multiple-inheritance-not-allowed-in-java-or-c) – Zhedar May 31 '15 at 12:12

1 Answers1

1

Java doesn't support multiple inheritance because of the "diamond problem" and other problems that arise from "increased complexity and ambiguity" as is explained in the wikipedia page on the matter

The creators of Java had a design goal of simplicity. That is why operator overloading with the added complexity of the "copy constructor" was also left out. That is why there is automatic memory management etc etc

most modern languages chose to discard this concept for the same reason.

Sharon Ben Asher
  • 13,849
  • 5
  • 33
  • 47