• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transient Fields  RSS feed

 
Shashank Sharma
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any body pls explain transient fields and serialization of objects
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Transient fields are fields that are not saved when you serialize an object. For more information about serialization, use Google to search for "java serialization tutorial". You'll find, for example, these tutorials:

Discover the secrets of the Java Serialization API
Introduction to Object Serialization
 
Bill Cruise
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Serialization is a mechanism built into the Java libraries that allows you to convert an object into a byte stream. You might want to do this to save an object to disk, make a copy of the object, or to transfer it over a network connection. In order to use the serialization mechanism in Java, and object must implement the Serializable interface.

You mark a field of a Serializable object as transient when you don't want that field to be a part of the serialized byte stream. You might choose to do this for several reasons. For example, the field itself might be an object that does not implement Serializable. Attempting to serialize the field would cause an exception. You might also have business reasons for making a field transient. The field could be data that you don't want to store, such as a password, or it could just be redundant data that you can recalculate once the rest of the object is deserialized.
 
Shashank Sharma
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!