This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interface" Watch "Interface" New topic
Author

Interface

Dipen Javia
Greenhorn

Joined: Jun 12, 2004
Posts: 5
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


Dipen Javia.
Leo Deegan
Greenhorn

Joined: Jun 15, 2004
Posts: 12
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

Joined: Jun 12, 2004
Posts: 5
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 ]
 
 
subject: Interface