• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Rules of Serializaton

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

I have a question.
I have the class
public class Test implements Serializable
{
public TestTwoClass classTwo = new TestTwoClass();
public int i;
...
}

After serialization and deserialization will the variable 'classTwo' reffer to the object TestTwoClass?

Are there any requirements to the TestTwoClass?

If TestTwoClass is not serializable, what value will the variable 'classTwo' has?

Thanks!

[ June 04, 2007: Message edited by: Simeon Cherniy ]
[ June 04, 2007: Message edited by: Simeon Cherniy ]
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If class TestTwoClass implements Serializable it would get the value TestTwoClass's var had when the object is being serialized. If not it would throw an Exception. You can provide code for custom serialization/deserialization.
[ June 04, 2007: Message edited by: Anupam Sinha ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anupam Sinha:
If class TestTwoClass implements Serializable it would get the value TestTwoClass's var had when the object is being serialized.



To further clarify: it would reference a *new* deserialized instance, *not* the original instance before serialization.
 
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic