I want to know concept of transient variable in java.
Thank you.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 30, 2012, 8:39 AM
Java also has two keywords which have never been used at all - and probably never will be - namely 'const' and 'goto'.
Satyapriya NayakPosted May 30, 2012, 6:54 AM
Declaring a Transient Variable
You use the transient keyword to indicate to the Java virtual machine that the indicated variable is not part of the persistent state of the object. Variables that are part of the persistent state of an object must be saved when the object is archived.
At this time, the transient marker is ignored by the Java runtime system. Future releases of the Java system will use the transient marker to implement various object archiving functions.
Like other variable modifiers in the Java system, you use transient in a class or instance variable declaration like this:
This statement declares an integer variable named hobo that is not part of the persistent state of the TransientExample class.
Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the val ue of the variable can't be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null
A transient variable is a variable that may not be serialized.
The transient variable is not persist when an object is stored
Please refer the below link
http://www.javabeat.net/qna/105-what-is-transient-variable-in-java/
Thanks
VulpesPosted May 30, 2012, 6:06 AM