static - Compile-time value-binding of Java constants -


according last note here:

"if primitive type or string defined constant , value known @ compile time, compiler replaces constant name everywhere in code value. called compile-time constant. if value of constant in outside world changes (for example, if legislated pi should 3.975), need recompile classes use constant current value."

suppose defined public constant pi (public static final double pi=3.14) in class a, , used constant pi within class b.

so - above spec, if change value of pi 3.14 to, 3.0 in class a, have re-compile class b effect of change in class b.

the q here is-- definition of "constant" in above spec? final keyword? static field member "qualify" constant in context? non-static field members out of context here-- values assigned @ run-time(?)

tia.

//===========================

edit:

the q here is: makes compiler decide bind value @ compile time. static keyword job itself. or there else it.

//=======================

in reference quick answer below keeps getting voted up:

the line on same page:

"the static modifier, in combination final modifier, used define constants. final modifier indicates value of field cannot change."

1.) "... also used define constants. ...": else defines constant.

2.) "... in combination with final modifier": final necessary make value bound in compile-time-- doubt is.

you did not read link mentioned?

constants

the static modifier, in combination final modifier, used define constants. final modifier indicates value of field cannot change.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -