aspose file tools*
The moose likes Beginning Java and the fly likes Purpose in an interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Purpose in an interface" Watch "Purpose in an interface" New topic
Author

Purpose in an interface

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
Can someone explain to me what exactly an interface is and when and why
you would use one?

Thanks.
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
Try this
Mani vannan
Ranch Hand

Joined: Aug 21, 2004
Posts: 185
hi,
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.


Manivannan
Ben Kittrell
Greenhorn

Joined: May 20, 2005
Posts: 6
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.

ArrayList 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 ArrayList 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.
 
jQuery in Action, 2nd edition
 
subject: Purpose in an interface