Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Transient Feild

 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends

Please make me understand what are Transeint feilds
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gaurav,

It seems you hate book reading.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A transient field is one whose state is not preserved when an object is Serialized.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you chandra
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic