This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Compile time constant means just that! A thing which is known to be constant at the time the program is compiled. For eg, final int i = 10; 'i' is a compile time constant because the compiler knows that as it is final, it will never ever change. On the other hand, int i = 10; is not a constant because, the value of i can be changed anywhere in the program. HTH, Paul. ------------------ Get Certified, Guaranteed! (Now Revised for the new Pattern) www.enthuware.com/jqplus
H, Aftab I think your question is over the Core section, but I glad to help you understand the mechanism of allocation of JVM. JVM uses two seperate heaps to handle the memory allocation. One is responsible for static allocation and another is for dynamic allocation. when you define a final varible, it is allocated in to a heap which cannot clloected by gc. So it stays in memorey until the application is over. All class definitions, the Constant Pool, and method tables are kept in a nongarbage collected heap. The second heap is split into two areas that grow in opposite directions. One area is used to hold object instances, and the other contains "handles" to those instances. The runtimeimage of fields and variables in your Java application that reference object instances do not actually contain pointers to those objects. They contain pointers to a special, fixed-size, heap-based memory object called a handle. The handle is a structure that contains two pointers: one to the object's method table and the other to the actual object instance. The advantage to this layout is that the handles never move in memory, so there is never a need to keep track of which variables point to which objects when updating pointers after compacting. You simply update the pointer value of the handle structure. So , now, you can understand what is compil-time constant, what is runtime varible. In fact, in my understanding, the runtime varible is not a dynamic one since its handler can not be changed during the application lifecycle. The above is just my view and just as reference, if there are wrong sections, plz point out.Thanks regds George