According to the very last note here:
"If a primitive type or a string is defined as a constant and the value is known at compile time, the compiler replaces the constant name everywhere in the code with its value. This is called a compile-time constant. If the value of the constant in the outside world changes (for example, if it is legislated that pi actually should be 3.975), you will need to recompile any classes that use this constant to get the current value."
Suppose i defined a public constant PI (public static final double PI=3.14) in class A, and
used this constant PI from within class B.
So - by the above spec, if I change the value of PI from 3.14 to, say 3.0 in class A, i have to re-compile class B to get the effect of that change in class B.
the Q here is-- what exactly is the definition of "constant" in the above spec?
is it the final keyword? does any static field member "qualify" as a constant in this context?
the non-static field members would be out of context here-- their values are assigned at run-time(?)
TIA.
//===========================
EDIT:
The Q here is: what makes the compiler decide to bind the value at compile time. does the static keyword do this job all by itself. or is there anything else into it.
//=======================
in reference to a quick answer below that keeps getting voted up:
the line on the same page:
"The static modifier, in combination with the final modifier, is also used to define constants. The final modifier indicates that the value of this field cannot change."
1.) "... is also used to define constants. ...": what else defines a constant.
2.) "... in combination with the final modifier": is final necessary to make the value bound in compile-time-- which i doubt it is.
Math.PIinstead.static finalclass member can break binary compatibility!