DonationCoder.com Forum

Main Area and Open Discussion => General Software Discussion => Topic started by: Josh on December 11, 2011, 03:39 PM

Title: Java Interfaces - huh?
Post by: Josh on December 11, 2011, 03:39 PM
I know there are some very well versed people on doco that are likely to understand this concept. Can someone explain to me how and why I would use a Java interface? I am coming from a VB/C++ background and really cannot wrap my head around why to use an interface.

Thoughts?
Title: Re: Java Interfaces - huh?
Post by: Eóin on December 11, 2011, 03:48 PM
A Java interface in what sense? As in an interface class?

If that's what you mean well they are like a purely abstract C++ class.

Multiple inheritance from non-abstract base classes seems to generally be considered "a bad thing" among many developers. So Java went the decision of only allowing single inheritance from a concrete class and multiple inheritance from interface classes.
Title: Re: Java Interfaces - huh?
Post by: mouser on December 11, 2011, 03:51 PM
What I told josh when he asked me this question, is that this is actually one of the more interesting and hot topics in programming language design.. the debate between Interfaces and OOP Inheritance.

It is well worth reading up on.. Perhaps people can recommend their favorite essays on the subject after a little web searching..
Title: Re: Java Interfaces - huh?
Post by: Josh on December 11, 2011, 04:09 PM
I am going through the basics of learning Java and stumbled on this page at oracle: http://docs.oracle.com/javase/tutorial/java/concepts/interface.html

This is where I started my search for info on interfaces and I figured, what better place to ask about them than doco?