Take the 2-minute tour ×

Possible Duplicate:
Why there is no multiple inheritance in Java, but implementing multiple interfaces is allowed

hi all, I am new to java and when I am try to use multiple inheritance concept in java its showing a compile time error.Why java does not support it.I heard about interface key word but do not know why java support it directly. please help me in this and explain.

share|improve this question

marked as duplicate by Bozho, BalusC, tim_yates, ninesided, oezi Sep 22 '10 at 9:58


3 Answers 3

up vote 9 down vote accepted

Multiple inheritance can be really difficult to understand. When you have a multiple inheritance with two classes which have methods in conflicts, how do you handle this ?

Of course solutions exist (in C++ for example) but the creators of Java decided it was way to complicated and not really in the Java philosophy (make development a lot easier).

From sun.com :

Multiple inheritance--and all the problems it generates--was discarded from Java. The desirable features of multiple inheritance are provided by interfaces--conceptually similar to Objective C protocols.
An interface is not a definition of a class. Rather, it's a definition of a set of methods that one or more classes will implement. An important issue of interfaces is that they declare only methods and constants. Variables may not be defined in interfaces.

Resources :

share|improve this answer

The main problem with multiple inheritance (alluded to by Colin and Rin) is known is The Diamond Problem.

I quote:

The diamond problem is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If a method in D calls a method defined in A (and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B, or C?

share|improve this answer

Because, it was hard to use it. Instead, Java has interface what is much better solutions.

share|improve this answer
