This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Transient static variables " Watch "Transient static variables " New topic

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="" 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.
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
I agree. Here's the link:
subject: Transient static variables
It's not a secret anymore!