A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
Purpose in an interface
Joined: Jun 05, 2001
May 20, 2005 06:56:00
Can someone explain to me what exactly an interface is and when and why
you would use one?
Joined: Aug 08, 2003
May 20, 2005 07:14:00
Joined: Aug 21, 2004
May 20, 2005 07:28:00
The above link colud have given a clear issue on Interface.. Interface is a skeleton, that doesnt have any functionality, but takes shape as it is implemented.
Joined: May 20, 2005
May 20, 2005 07:35:00
Wow, great question, hehe.
My advice would be to not try and understand it, unless you think you need it.
But to some it up, and interface allows you to change the implementation, without changing the interface. It also allows you plug different objects in the same hole.
Think of collections.
and Vector but implement the List interface. The benifit is that you can have a method that takes a List as an argument, and you can pass an
or a Vector to it.
What does an Interface do? It ensures that the classes that implement it all have the same methods. This way the compiler can rest assured that the methods it calls on an object will be there.
Kind of hard to grok, but it's an awesome concept.
I agree. Here's the link:
subject: Purpose in an interface
Writing an Interface
How To Call Two Different Classes From the Main Program Using the Same API?
Home interface or Home Interface stub
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014