This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Index in serialized Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Index in serialized Collection" Watch "Index in serialized Collection" New topic
Author

Index in serialized Collection

Pablo Vilas
Greenhorn

Joined: Sep 14, 2011
Posts: 5

Hello,

if I serialize a class that contains a collection, that guarantee the object index don´t change between serialization and deserialization?

Thank you.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

What's an "object index"?
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3001
    
    9
Pablo, it depends on the collection. If you've got some sort of serializable List (like ArrayList or LinkedList), then each entry in the List has an index, and the value of that index will not change when you serialize and deserialize the List. However if you've got some other collection, like a HashSet, there is no notion of an index, and there is not necessarily any guarantee that the elements will be observed in the same order (e.g. if you iterate through the collection).
Pablo Vilas
Greenhorn

Joined: Sep 14, 2011
Posts: 5

Paul Clapham wrote:What's an "object index"?


The index of an object inside a List. Sorry about my English
Pablo Vilas
Greenhorn

Joined: Sep 14, 2011
Posts: 5

Mike Simmons wrote:Pablo, it depends on the collection. If you've got some sort of serializable List (like ArrayList or LinkedList), then each entry in the List has an index, and the value of that index will not change when you serialize and deserialize the List. However if you've got some other collection, like a HashSet, there is no notion of an index, and there is not necessarily any guarantee that the elements will be observed in the same order (e.g. if you iterate through the collection).


Thank you very much Mike. I shall use an Arraylist.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Index in serialized Collection
 
Similar Threads
WA #1.....word association
Iterator vs for loop
Vector
Index in List collection
Hello a collection problem