This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface  RSS feed

 
Dipen Javia
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am *really* confused what an Interface is and what Interface does. I would really appreciate if someone could explain me what an Interface is and what it does with an example if possible.

Thanx in advance
 
Leo Deegan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dipen, here's one main use for an interface:

An interface is used to declare methods without defining their behavior. The behavior is implemented in the classes that implement that interface.

Take, for example, the following interface.



The above interface declares a method (operateOn), but does not define what the method does. The following classes provide different behavior by implementing the interface.

 
Dipen Javia
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Leo,

Thank you so much for exaplaing the use of an interface with an example. I really appreciate your help.
[ June 16, 2004: Message edited by: Dipen Javia ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!