• 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

static final transient int i=100??

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this code compiles


what modifiers cannot be used with transient?
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe transient simply declares that a member variable is not part of the objects persisted state, so you should be able to apply all valid modifiers to it (the same modifiers you can apply as if it were not transient). transient only really affects the variable when an object is serialized, etc. Someone correct me if I am wrong.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that's indeed what transient does.
I find it a bit weird to see it used like this as statics are not part of an object instance and therefore not serialised either which would have me think the particular combination might be illegal, but apparently it's not
K&B doesn't explicitly exclude the combination "transient final" though, listing that an instance variable can be marked "transient or final" which logically means the combination is legal.
 
reply
    Bookmark Topic Watch Topic
  • New Topic