DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Java Interfaces - huh?  (Read 4,910 times)

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,411
    • Gathering Badge
    • Official Forum Clown
    • Coding Snacks
    • Plugin Coding Medal
    • Volunteers/Staff
    • Military Service Badge - US Army
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Java Interfaces - huh?
« on: December 11, 2011, 09: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?
Strength in Knowledge

Eóin

  • O'Callaghan
  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
Re: Java Interfaces - huh?
« Reply #1 on: December 11, 2011, 09: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.
Interviewer: Is there anything you don't like?
Bjarne Stroustrup: Marketing hype as a substitute for technical argument. Thoughtless adherence to dogma. Pride in ignorance.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Java Interfaces - huh?
« Reply #2 on: December 11, 2011, 09: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..

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,411
    • Gathering Badge
    • Official Forum Clown
    • Coding Snacks
    • Plugin Coding Medal
    • Volunteers/Staff
    • Military Service Badge - US Army
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Re: Java Interfaces - huh?
« Reply #3 on: December 11, 2011, 10: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?
Strength in Knowledge

Original address: https://www.donationcoder.com/forum/index.php?topic=29233.0