Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interfaces instead of multiple inheritance?

843789Jul 10 2009 — edited Jul 11 2009
I've read that "The Java programming language does not permit multiple inheritance , but interfaces provide an alternative."

But I also read contradictory information-There are no method bodies in an interface.

Java interfaces only contain empty methods? Apparently, if I want to share a method among classes, I have to re-write the methods in each class that implements the interface. That doesn't seem at all like multiple inheritance. Am I missing something?

It seems that I will have to cut and paste the implementation code from one class to another, and if I change the methods, I have to cut and paste it all over again.

I've read that interfaces save a lot of time re-writing methods, but how?

Does this really provide the same capabilities as multiple inheritance, or am I missing something?

Thanks,
Pat
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2009
Added on Jul 10 2009
11 comments
276 views