wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface non-access modifiers 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 "Interface non-access modifiers" Watch "Interface non-access modifiers" New topic
Author

Interface non-access modifiers

Andreas Sandberg
Ranch Hand

Joined: Sep 14, 2005
Posts: 31
Folks,

Since interfact instance (non-local) variables are public static and final, why can they not have the keywords volatile or transient applied? Perhaps it doesn't make sense to use the keyword transient as the instance variables already belong to the class and therefore any object or request to that variable must reconcile it's own copy from main memory so there is never a chance of a race type condition. Also, I know transient is to be used for specifying when an instance variable shouldn't be serialized, correct? So are static variables never serializable then? Thanks for the help!

-Andreas


"When the compilers not happy ain't nobody happy"
agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579
Folks,

Since interfact instance (non-local) variables are public static and final, why can they not have the keywords volatile or transient applied? Perhaps it doesn't make sense to use the keyword transient as the instance variables already belong to the class and therefore any object or request to that variable must reconcile it's own copy from main memory so there is never a chance of a race type condition. Also, I know transient is to be used for specifying when an instance variable shouldn't be serialized, correct? So are static variables never serializable then? Thanks for the help!

I Think You got answer of your first problem.If you are left with
why final and volatile can't come together then remember
that final variables can not be changed..........but volatile means its
value can be changed anytime.So final and volatile together are contradictory.Right?
Andreas Sandberg
Ranch Hand

Joined: Sep 14, 2005
Posts: 31
Doh! Thanks for pointing the obvious out to me. I thought too much about that question instead of steping back for a second. Guess I've studied for enough today. Thanks though!
 
Consider Paul's rocket mass heater.
 
subject: Interface non-access modifiers
 
Similar Threads
Doubt in StackOverflowError
why a transient variable can be declared with static modifier??
Is transient allowed with static?
final and transient
Serialization