Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
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 11-06-2007, 08:29 PM
Member
 
Join Date: Nov 2007
Posts: 97
javaplus is on a distinguished road
Serializing Arrays
We can serialize objects of classes which implement Serializable interface.

Code:
import java.io.Serializable; public class MyClass implements Serializable{ ... }
I also understand that we can serialize Vectors as they also implement Serializable interface. Can we serialize arrays? If yes, then of which type?

Thanks in advance.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-06-2007, 09:11 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,104
hardwired is on a distinguished road
Can we serialize arrays?
You could create an ArrayList with an array. ArrayList is also serializable.
Otherwise, probably.
If yes, then of which type?
Possibly most any.
You might be able to make a class (implementing Serializable) to do the serializing for you; it could specify the array type and include the necessary methods to read and write the array. Or you could have the array (whose type implements Serializable) and the methods included in another class. This is speculation: I have never tried these.
Object Streams
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-08-2007, 10:00 AM
Member
 
Join Date: Nov 2007
Posts: 97
javaplus is on a distinguished road
Ok thanks. What I understood is that if we have an Array of a type A (where A can be Integer, String etc), and A implements Serializable, then it can also be serialized.

I will try this.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-08-2007, 10:09 AM
Member
 
Join Date: Nov 2007
Posts: 97
javaplus is on a distinguished road
It worked. I tried serializing an int array it worked. Thanks.
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
new to arrays jimJohnson New To Java 1 04-08-2008 03:45 PM
2D-Arrays kbyrne New To Java 1 02-07-2008 11:08 PM
arrays help Warren New To Java 6 11-23-2007 08:23 PM
Serializing Arrays JavaForums Java Blogs 0 11-09-2007 11:10 PM
How do I omit an object when serializing? Hasan Advanced Java 1 05-31-2007 05:18 PM


All times are GMT +3. The time now is 02:03 AM.


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