Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the need of interface????????

 
rahul mehra
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is interface needed in java.... if we say that any class which implememnts a particular interface has the flexibility to define its method in its own way..then we might as well as declare a class with the required method....


why do we need to define an interface.... ???


can anybody give me the basic idea.....
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Sun Java Tutorial has a section on interfaces and inheritance. It explains why and when you might want to use them
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interfaces are used to define contract,
They are also used to achieve runtime polymorphism.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic