• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transient Feild

 
Gaurav Pavan Kumar Jain
Ranch Hand
Posts: 168
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends

Please make me understand what are Transeint feilds
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gaurav,

It seems you hate book reading.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A transient field is one whose state is not preserved when an object is Serialized.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gaurav,

You would have to understand the Serialization to well understand the "transient". Anyway if you mark any member variable (yeah, only member variables can be marked transient) transient, while serialization takes place they are left or say are not included in instance state.
Other instance variables (neither marked transient nor static) come under the state of the object and so serialized (if they are serializable).

You make a member variable transient when you dont require to make that member included in the serialization process. More literally the writeObject() of the ObjectOutputStream class leaves those fields.

One more scenarion may come when you are forcibly make your member varialbe transient and that is you have a reference variable of the class which is not Serializable (does not implement the Serializable interface) so to make your class Serializable you must make that reference variable which your class has "transient" so, that non serializable reference could not hindle the serialization process of your class instances.


Serialization is the process of converting instance of your class into
streams of bytes and save it to the persistent storage (a file on the disk).
So you can deserialize the stream back to the instance when required.
"Serialization and Deserialization" are very helpful phenomenon to send the instances over the network, at the two ends the "ser and deser" process takes place.


For detailed info, refer to any book.

Thanks and Regards
cmbhatt
 
Gaurav Pavan Kumar Jain
Ranch Hand
Posts: 168
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you chandra
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic