This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Tranient variable, help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Tranient variable, help!" Watch "Tranient variable, help!" New topic
Author

Tranient variable, help!

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
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

Joined: Oct 28, 2000
Posts: 4
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

Joined: Nov 02, 2000
Posts: 65
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tranient variable, help!
 
Similar Threads
Can they mix???
transient variale
is trasient + static valid ??
transient variable with static,final modifiers
valid combinations of Modifiers like static,native,transient etc