Reputation: 25452
I know Java objects, instance variables are created and live in the heap, while the local variables and object references are created and live in the stack.
What about the "class" itself where does it live?
Am asking this because when you create static variables you call them using the class name, e.g.
Math.round()
When Math class is created, where does it live in memory (heap or stack)
Gath
Upvotes: 2
Views: 964
Reputation: 6054
You can read more about the Permanent Generation (where classes, methods, etc are stored) here:
http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation
Note however, that when you call a static method Java is actually making an internal instance of the object behind the scenes, so you are really calling the method on a "behind-the-scenes" global instance of the object.
Upvotes: 0
Reputation: 12575
Java classes lives in Permanent Generation heap
.Also the interned string pool is stored here.
Permanent Generation heap contains:
Upvotes: 2