This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tranient variable, help!

 
sarim raza
Ranch Hand
Posts: 232
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following declaration(as a member variable) is legal.
static final transient int maxElements = 100;
A) True.
B) False.
Can someone explain why answer is A, since RHE says that a transient var cant be static or final ?
 
Abhijit Natu
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried putting this line of code in a JAVA program and it works without giving any compile time error . So I guess Transient modifier is only used to tell that the variable need not be saved during serialization .
JAVA GURUs could please explain this in a little more detail !!
 
Oliver Grass
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sarim raza:
Can someone explain why answer is A, since RHE says that a transient var cant be static or final ?

Hi Sarim,
you're right and not :-))
RHE states in a note that transient variables can't be final or static. BUT in the errata of the RHE they say, "The Note should be deleted"
So transient variables can be final static....
Hope that helps
Oliver
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic