Sunday, July 11, 2010

Java constant values are resolved at compile time or runtime?

Java constants are basically variables defined as static final in any class or interface. At compile time when java classes are generated constant values are placed at all the places where the constant is referred. At runtime the defined constant or the class in which constant is defined does not come into picture at all. So if at sometime you change some constant in any file and just try to replace the class file in the jar or in production, it will not work because the value need to be replace where that constant is referred which is done at compile time.

No comments:

Post a Comment