This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Index in serialized Collection  RSS feed

 
Pablo Vilas
Greenhorn
Posts: 5
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's an "object index"?
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:What's an "object index"?


The index of an object inside a List. Sorry about my English
 
Pablo Vilas
Greenhorn
Posts: 5
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!