Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transient Variable

 
Ashish Agarwal
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lisa Yu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Lisa
Ashish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic