top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What is transient variable in JAVA

+6 votes
100 views
What is transient variable in JAVA
posted Dec 6, 2013 by Prachi Agarwal

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
The transient keyword in Java is used to indicate that a field should not be serialized.

Variables can be marked transient to indicate that they are not part of the persistent state of an object.

For example, you may have fields that are derived from other fields, and should only be done so programmatically, rather than having the state be persisted via serialization.

1 Answer

+1 vote
 
Best answer

transient is used to indicate that a class field doesn't need to be serialized. Probably the best example is a Thread field. There's usually no reason to serialize a Thread, as its state is very 'flow specific'.

answer Dec 8, 2013 by Neeraj Pandey
Similar Questions
+1 vote

Why we need transient keyword to prevent serialization of a particular data member. we can also make it static because static data member can not be serialized.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...