I want to know WHY the volatile and final keywords are not used on the same variable?
Printable View
I want to know WHY the volatile and final keywords are not used on the same variable?
What does the JLS say about those two modifiers, and then you tell us, what you think the reason might be.
IMO it is extremely obvious why they can't (or at least why it makes absolutely no sense to even attempt to do so) be used on the same variable.
Your title is asking about transient vs volatile while your question is asking about volatile and final keywords. You may want to cross check your posts more carefully before posting them.
volatile says the variable can be changed from multiple threads (no thread local caching) while final says the variable's value cannot be changed. You should now see that it doesn't make sense to use both on a variable.