• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Purpose in an interface

 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain to me what exactly an interface is and when and why
you would use one?

Thanks.
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this
 
Mani vannan
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Kittrell
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic