Generally, final static members especially, variables (or static final of course, they can be used in either order without overlapping the meaning) are extensively used with
I'm unable to differentiate between a final and a final static member. The final static member is the one which is a static member declared as final or something else? In which particular situations should they be used specifically?
Use a final static
when you want it to be static
. Use a final
(non-static) when you don't want it to be static
.
A static variable or a final static variable can never be declared inside a method neither inside a static method nor inside an instance method. Why?
Design decision. There's just no way to answer that without asking James Gosling.
The following segment of code accordingly, will not be compiled and an compile-time error will be issued by the compiler, if an attempt is made to compile it.
Because it violates the rule you just described.