Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-11-2007, 02:06 PM
Member
 
Join Date: Nov 2007
Posts: 97
javaplus is on a distinguished road
Implementing Serializable interface
Please review the code below:

Code:
public class ClassA implements Serializable{ ...}
I implemented Serializable interface and wrote methods according to my requirement. I did not implement any method of Serializable interface. I know that when you implement an interface, you have to implement its methods. I can compile my class and no error are shown.

Is this some special behavior of interface?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-11-2007, 06:22 PM
Senior Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 102
wsaryada is on a distinguished road
This is called as a marker interface, which is use to mark a class for serialization purposes. By implementing this interface Java know that this class can be serialized.

Yes, you don't need to implement a method when create a class a serializable because the interface itself doesn't define any method. But there are some rules for creating a good serializable class, you can read it here: Implementing Serializable.
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-12-2007, 01:11 PM
Member
 
Join Date: Nov 2007
Posts: 97
javaplus is on a distinguished road
Thanks a dozen for making this clear.
So, is this right to say that "marker interfaces" are those interfaces, that have no method in them.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-12-2007, 03:03 PM
Senior Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 102
wsaryada is on a distinguished road
Well, not really I think. It can have methods or fields. For more information see here: Marker interface pattern - Wikipedia, the free encyclopedia
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-18-2007, 02:29 PM
Member
 
Join Date: Dec 2007
Posts: 3
jaykishan is on a distinguished road
It is also known as null interface....but still you may use readObject() and writeObject() method to serialize and deserialize object....
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
An interface extending an interface(I) JavaForums Java Blogs 0 03-12-2008 05:00 PM
Implementing an interface bugger Advanced Java 1 01-09-2008 03:35 PM
Implementing ActionListener interface JavaForums Java Blogs 0 12-19-2007 11:54 PM
Creating a Thread (implementing Java Runnable Interface) JavaForums Java Blogs 0 12-19-2007 11:31 AM
Implementing Interface mew New To Java 2 12-06-2007 11:09 PM


All times are GMT +3. The time now is 02:12 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org