wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Transient variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Transient variables" Watch "Transient variables" New topic
Author

Transient variables

Neelima Mohan
Greenhorn

Joined: May 23, 2010
Posts: 27
Why cant transient variables be final or static?

Thanks,
Neelima
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

The transient keyword is used in serialization. Since only instances can be serialized, and static fields are never serialized, it wouldn't make much sense to allow a combination of transient and static.

Transient variables are not serialized or de-serialized. If they were final they could never again get a value after de-serializing. They will lose the value they had and that value can never again be set, rendering them virtually useless.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Neelima Mohan
Greenhorn

Joined: May 23, 2010
Posts: 27
thanks :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transient variables
 
Similar Threads
entity bean with CMP and CMT
Serailzable Problem....
partial serialisation...
transient variables
static are kept away from the process of serialization