Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Problem in understanding -how interface helpful Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in understanding -how interface helpful" Watch "Problem in understanding -how interface helpful" New topic
Author

Problem in understanding -how interface helpful

abdul ambalam
Greenhorn

Joined: Dec 01, 2003
Posts: 1
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in understanding -how interface helpful