• 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

Serializable fields

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class fields with the following modifiers will not be serialized

1) private
2) static
3) transient
4) protected
Answer is 2 & 3!! Why static??? I know transient field will not be serialized???
Thanks
Amish
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amish,
As far as I know, serialization is for objects.
Static key word is for class. so both doesn't go together.
This is just a guess.

-Tony.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another thoughts:
The class variables are not important to be serialized because they are shared between all of your instances of the class. Should they be serialized, deserialized each time an object is? Obviously not. It seems to me that the state that makes different an instance of the other are the instance fields. Because static variables are identical for all of them.
Also, wherever you deserialized the object you will need the class there to use it. And there (in the class) the static variables go.
 
reply
    Bookmark Topic Watch Topic
  • New Topic