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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Serialization Doubt" Watch "Serialization Doubt" New topic
Author

Serialization Doubt

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575



here rob is transient variable...but still i can serialize the variable?? please anyone clarify the doubt
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38426
    
  23
Will that class compile?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

yes
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38426
    
  23
It didn't compile when I tried it. There is no "a" declared.

And I will let you out of your misery by giving you the Java™ Language Specification link.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Campbell Ritchie wrote:It didn't compile when I tried it. There is no "a" declared.


i am sorry. when i copy and past, forget to paste the declaration of "a". i changed the above my post.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Campbell Ritchie wrote:
And I will let you out of your misery by giving you the


Really it helped me lot. Thank you Campbell .
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38426
    
  23
You're welcome

You learned a lot more by having to look up the JLS than if I had simply said "no" to your first question.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Cool, an entire class named after me!

Transient fields are ignored when the object they are declared in is serialized, but if you serialize them directly (like in your code) then they will get serialized.

If you would have replaced "writeObject(rob)" with "writeObject(this)", then the rob field would most definitely be skipped.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks Rob
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Rob Prime wrote:Cool, an entire class named after me!


I wonder of int "a=10" refers to age


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Maneesh Godbole wrote:
Rob Prime wrote:Cool, an entire class named after me!


I wonder of int "a=10" refers to age

Only mentally.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Serialization Doubt