aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interface" Watch "Interface" New topic
Author

Interface

Albina Amalraj
Greenhorn

Joined: Dec 19, 2007
Posts: 3
Any class that implements a Interface should implement all the methods defined in interface..My question is
How far it is feasible in Real time programming implementing all methods?
Is it not a extra burden to specify all the methods in class???
Thanks
Albina
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Albina Amalraj:
...Is it not a extra burden to specify all the methods in class??? ...

Well, this "burden" should be weighed against the advantages of interfaces and the long-term benefits they can provide in terms of flexibility and maintenance.

Also note that abstract classes can provide partial implementation of an interface to make concrete implementation easier. For example, AbstractCollection "provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface." In turn, AbstractList extends AbstractCollection and provides skeletal implementation of the List interface. So when ArrayList extends AbstractList, it inherits much of the implementation required to satisfy the Collection and List interfaces.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Albina Amalraj
Greenhorn

Joined: Dec 19, 2007
Posts: 3
Thanks for the explaination..

Albina
Petrus Pelser
Ranch Hand

Joined: Feb 20, 2006
Posts: 132
If you find yourself implementing just one method in an interface that specifies several then you should think of creating an adapter for the interface. A lot of empty implemented methods makes your code ugly and difficult to read.
 
Consider Paul's rocket mass heater.
 
subject: Interface
 
Similar Threads
Optional Methods in interface
Thread Doubt
usefulness of java interfaces
Class in an interface
interface as pointer