I know that local variables are kept in the stack. The instance variables are kept in the heap. I just wanted to know
1. where the static variables are kept. 2. where is the .class file loaded. It must be in the same memory area as the java runtime but do we have any particualr name for place where .class files are loaded.
In the heap itself. Static variables are stored only once, no matter how many objects are created
Originally posted by Vijay Raj:
2. where is the .class file loaded. It must be in the same memory area as the java runtime but do we have any particualr name for place where .class files are loaded.
Again in the heap memory. Everything is stored in the Heap itself.
The below text from Wikipedia might help:
When an object from the MyObject class is created for the first time. The JVM searches the file system for the definition of the class. The CLASSPATH environment variable contains locations where Java classes are stored. The JVM is looking for the 'MyObject.class' file. Depending on which package the class belongs to, the package name will be translated to a directory path.
When the 'MyObject.class' file is found, the JVM's class loader loads the class in memory. The JVM stores the code in memory, allocates memory for the static variables, and executes any static initialize block. Memory is not allocated for the object member variables at this point, memory will be allocated for them when an instance of the class, an object, is created
You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>