• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Serializable

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

If anyone can explain me the below para,
"If you are a serializable class,but your superclass is NOT serializable, then any instance variable you INHERIT from that superclass will be reset to the value they were given during the original construction of the object.This is because the non-serializable class constructor WILL run."

thanks in advance,
Chand.
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me show you what it means with an example.

Let's say you have a non-serializable Parent class



Now let's define a Child class, and make it Serializable:



Now let's define a Child object



Now, let's serialize the child object:



Now, let's deserialize it in the same object reference:



Now, let's print the deserialized object:



As you can see, the deserialization process did not set the value of the variable x, because it belongs to the Parent class, which is not serializable.

In other words, only the Child class was serialized.

I hope this helps!
 
Did you just should on me? You should read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic