It's not a secret anymore!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Transient Variable 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 Variable" Watch "Transient Variable" New topic
Author

Transient Variable

Ashish Agarwal
Ranch Hand

Joined: Dec 02, 2000
Posts: 36
Its written in R&H that transient variables cannot be Static or
final. See Pg-90.
But the following code compiles and run fine.
Can anybody explain.
class test13{
transient static int x = 85;
transient final int y = 85;
transient final static int z = 85;
public static void main(String args[]){
print();
}
public static void print(){
System.out.println("Test");
}
}
Thanx.
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
OK; I'm on vacation on The Beach (Atlantic Ocean)... Translation: I have no compiler with me
But if you are willing to accept a somewhat educated answer
I don't see the conflict in a variable being static, final, or transient.
For Serialization purposes, neither static nor transient variables are included in the byte stream that is the result of Serialization.

Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Lisa Yu
Greenhorn

Joined: Dec 27, 2000
Posts: 3
From R&H's errata : http://scooter.sybex.com/erratatracking.nsf/weberrataform?OpenForm&ISBN=2700
Page 90
Corrected in the third printing: The Note on the page should be deleted.
Ashish Agarwal
Ranch Hand

Joined: Dec 02, 2000
Posts: 36
Thanx Lisa
Ashish
 
 
subject: Transient Variable
 
Similar Threads
valid combinations of Modifiers like static,native,transient etc
Which of the Following is True?
Where should we write static final transient
Miscellenous Code for Transient Variable
static final transient int i=100??