File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface

 
Albina Amalraj
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Albina Amalraj
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the explaination..

Albina
 
Petrus Pelser
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic