transient keyword

// By:Team // No Comment

Email this to someonePrint this pageShare on Google+2Share on Facebook0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest0Share on StumbleUpon0

The transient keyword is used in serialization. If you define any data member as transient, it will not be serialized. Let’s take an example, I have declared a class as Student, it has three data members id, name and age. If you serialize the object, all the values will be serialized but I don’t want to serialize one value, e.g. age then we can declare the age datamember as transient.

Example of transient keyword

In this example, we have created the two classes Student and Persist. One data member of the Student class is declared as transient, it value will not be serialized. If you deserialize the object, it will return the default value for transient variable.

 


 

Email this to someonePrint this pageShare on Google+2Share on Facebook0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest0Share on StumbleUpon0

About Team

Browse Archived Articles by Team

Related

Sorry. There are no related articles at this time.