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

Problem in understanding -how interface helpful

 
abdul ambalam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
interface does not have method implementation. only class which implements interface must implememt all the methods defined in interface.
My question is why should we implement interface as we can write our own code. In java, Serializable and Cloneable dont have anything inside. How it is useful in serializing and cloning objects. does compiler have anything to understand these interfaces. I have many question regarding interfaces.
Can anyone answer to all the possible questions reg-interfaces. Thankyou.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abdul,
The interface is a way of declaring your intent. While Serializable doesn't have any required methods, you are telling the compiler that it is ok to serialize your object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic