aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Transient static variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Transient static variables " Watch "Transient static variables " New topic
Author

Transient static variables

Gagan Indus
Ranch Hand

Joined: Feb 28, 2001
Posts: 346
( 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 (/^_^\)


Gagan (/^_^\) SCJP2 SCWCD IBM486 <br />Die-hard JavaMonk -- little Java a day, keeps you going.<br /><a href="http://www.objectfirst.com/blog" target="_blank" rel="nofollow">My Blog</a>
ashok khetan
Ranch Hand

Joined: Jul 29, 2001
Posts: 153
member var can be declared as both transient and static.
ashok.
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
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


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
 
 
subject: Transient static variables