you can't implement multiple inheritance in java
and as georgemc said it can only be done through interfaces or attain ur results using single inheritance eg: if A,B class are inherited by C classthen what u can do is
class A
// body
class B extends A
// body
class C extends B
// body
that way u will be able to inherit the features of A & B in C.
> how to implement multiple inheritance in java
Multiple inheritance of type is in the language so you just start using it.
Java has single inheritance of implementation so if you want multiple inheritance of implementation you have to simulate it using an interface for the type and a delegated class for the implementation.
> Not with the "extend" keyword, only with the
> "implements" keyword. But an interface can EXTEND
> several interfaces but implement none. Read my last
> post again.
Which word you use is irrelevant. extends and implements really mean the same thing--"inherits from". It's just that in certain situations only one is legal and in other situations only the other is legal. It's not like you go around deciding "Hmmm, should I use extends or implements? If I use extends, I'll only be able to inherit once."
> > Which word you use is irrelevant.
>
> No it's not and I think Puce has it right here
> actually.
Nothing he's said is incorrect. He just seems to be putting too much weight on the specific word used to express the inheritance, when that's not relevant here.
Well, as far as I can remember the UML terms, classes don't inherit from interfaces, they implement them. Classes inherit from classes and interfaces inherit from interfaces. In these terms multiple inheritence in Java does only exist for interfaces.
But I agree, that you don't have a choice to use either the extends or the implements keyword once the type (interface or class) is fixed. And the instanceof operator does not destinguish between 'implements' and 'extends' either.
But consider this comment only as a side note. Maybe I was just working up the fact that you actually can have a comma separated list of types after the extends keyword, when I thought for such a long time you can not. Though this is only true for interfaces extending interfaces, which makes perfect sense. :-)
Have a nice evening!
-Puce