aspose file tools*
The moose likes Java in General and the fly likes Please help me to understand interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Please help me to understand interfaces" Watch "Please help me to understand interfaces" New topic
Author

Please help me to understand interfaces

t andrews
Greenhorn

Joined: Oct 29, 2003
Posts: 2
I guess I am having difficulty understanding the �why� of interfaces and I would really appreciate someone helping to clear this up for me. I understand that interfaces can inherit from other interfaces and that classes can implement multiple interfaces and I understand that this is a key difference between interfaces and inherited classes. What I don�t get is why you actually use interfaces and this is where I�m coming from. Interfaces contain no code bodies and all the methods for an interface must be implemented in the class. This confuses me because I don�t understand why the interface is used if the class has to write the implementation for all of the methods. Obviously I am missing something that is really profound; please help me to understand why the interface is used instead of just writing the members needed with no reference to an interface.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5018
    
    8

see http://java.sun.com/docs/books/tutorial/java/concepts/interface.html
and http://www.javaworld.com/jw-12-1998/jw-12-techniques.html


Junilu - [How to Ask Questions] [How to Answer Questions]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The answers to "why use interfaces" or "why use polymorphism" will take you into all the coolest OO theory. If you're writing two or three classes to satisfy an assignment you might not run into a need. But in architecting larger systems you can add major goodness with some advanced techniques. Drop down to the OO, UML and other cool stuff forum for that kind of talk.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help me to understand interfaces