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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted May 30, 2012, 2:06 AM EDT
Satyapriya NayakRank #47 · 31.5K reputationPosted May 30, 2012, 2:54 AM EDT
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
VulpesRank #55 · 29.2K reputationPosted May 30, 2012, 4:39 AM EDT
Java also has two keywords which have never been used at all - and probably never will be - namely 'const' and 'goto'.