Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transient static variables

 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
( Khalid , page 126 )
in KAM book , for transient variables , it is stated dat :

.... the transient modifier cannot be specified for static variables , as these do not belong to objects ....

I understand tht static-variables are not-saved while serialization , but compiler do not complain specifying static-vars to be transient , as transient static int i =0 ; is valid .
( any modification to above statement is not mentioned in KAM errata either )
any opinions ?


------------------
Gagan (/^_^\)
 
ashok khetan
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
member var can be declared as both transient and static.
ashok.
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gagan,
You can declare a variable both 'static' and 'transient', the compiler won't raise an error. It's just redundant.

------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic