title: Compile-time value-binding of Java constants
body: <p>According to the very last note <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html" rel="nofollow">here</a>: </p>
  
  <p>"<em>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.</em>"</p>
  
  <p>Suppose i defined a public constant <code>PI</code> (<code>public static final double PI=3.14</code>) in <code>class A</code>, and 
  used this constant <code>PI</code> from within <code>class B</code>. </p>
  
  <p>So - by the above spec, if I change the value of <code>PI</code> from 3.14 to, say 3.0 in <code>class A</code>, i have to re-compile <code>class B</code> to get the effect of that change in <code>class B</code>. </p>
  
  <p>the Q here is-- what exactly is the definition of "constant" in the above spec? 
  is it the <code>final</code> keyword? does any <code>static</code> 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(?) </p>
  
  <p>TIA. </p>
  
  <p>//===========================</p>
  
  <p>EDIT:</p>
  
  <p>The Q here is: what makes the compiler decide to bind the value at compile time. does the <code>static</code> keyword do this job all by itself. or is there anything else into it. </p>
  
  <p>//=======================</p>
  
  <p>in reference to a quick answer below that keeps getting voted up:</p>
  
  <p>the line on the same page:</p>
  
  <p>"<em>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</em>."</p>
  
  <p>1.) "... is <strong>also</strong> used to define constants. ...": what else defines a constant.</p>
  
  <p>2.) "... <strong>in combination with</strong> the final modifier": is <code>final</code> necessary to make the value bound in compile-time-- which i doubt it is. </p>