• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

transient variable with static,final modifiers

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
in boons book it is written thet transient variable cannot be declared as static or final.
but i hope this is wrong transient variable is allowing me to declare as static as well as final.
need your suggestions..
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the JLS to make sure if you want. RHE says that transient variables will not be on the exam (other than knowing that 'transient' is a keyword). And remember, just because a compiler allows something doesn't mean it's right according to the JLS and for exam purposes. I have seen a handful of instances where something works in a given compiler, but is not supported by the JLS. Always go with what the JLS says for exam purposes!
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is what JLS says on it:
The Syntax is :
FieldModifiers:
FieldModifier
FieldModifiers FieldModifier
( Which, in lex terms means that the token FieldModifiers consists of either FieldModifier or FieldModifiers and a FieldModifier )
( the token FieldModifier is defined as )
FieldModifier: one of
public protected private
static final transient volatile
"A compile-time error occurs if the same modifier appears more than once in a field declaration, or if a field declaration has more than one of the access modifiers public, protected, and private."
"If two or more (distinct) field modifiers appear in a field declaration, it is cus-tomary, though not required, that they appear in the order consistent with that shown above in the production for FieldModifier."
So I guess that there is no such restriction according to JLS.
cheers,
vivek
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic