topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 11, 2024, 4:58 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Java Interfaces - huh?  (Read 3483 times)

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Points: 45
  • Posts: 3,411
    • View Profile
    • Donate to Member
Java Interfaces - huh?
« 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?

Eóin

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
    • View Profile
    • Donate to Member
Re: Java Interfaces - huh?
« Reply #1 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.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Java Interfaces - huh?
« Reply #2 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..

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Points: 45
  • Posts: 3,411
    • View Profile
    • Donate to Member
Re: Java Interfaces - huh?
« Reply #3 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.c...cepts/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?