24 - Java Serialization with static fields - Code Demo

Veröffentlicht am: 02 Dezember 2022
auf dem Kanal: Rishi’s programming channel
216
2

‪@backstreetbrogrammer‬

--------------------------------------------------------------------------------
Chapter 10 - Serialization with static fields
--------------------------------------------------------------------------------
Static fields are NEVER saved as part of the object’s state.

We should think of static variables purely as CLASS variables. They have nothing to do with individual instances. And serialization applies only to OBJECTS.

Suppose we have 3 instances of a Serializable class =| all of which were serialized at different times, and thus all of which were saved when the value of a static variable in the class was different.

Now, if static variables were serializable, which of the 3 instances would win ? OR, Which instance’s static value would be used to replace the one currently in the one and only class that’s currently loaded ?

==| This is a problem… that’s why, static fields are never part of serialization / deserialization process.


Java Serialization Playlist:    • Java Serialization  
Java Serialization Github: https://github.com/backstreetbrogramm...

Dynamic Programming Playlist:    • Dynamic Programming  
Dynamic Programming Github: https://github.com/backstreetbrogramm...

#java #javadevelopers #javaprogramming #javaserialization


Auf dieser Seite können Sie das Online-Video 24 - Java Serialization with static fields - Code Demo mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Rishi’s programming channel 02 Dezember 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 216 Mal angesehen und es wurde von 2 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!