Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Serialization Doubt  RSS feed

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


here rob is transient variable...but still i can serialize the variable?? please anyone clarify the doubt
 
Campbell Ritchie
Marshal
Posts: 55668
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will that class compile?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
Campbell Ritchie
Marshal
Posts: 55668
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 55668
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Cool, an entire class named after me!


I wonder of int "a=10" refers to age
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:
Rob Prime wrote:Cool, an entire class named after me!


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

Only mentally.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!