[英]Where do java class live?
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. 我知道Java对象,实例变量已创建并存在于堆中,而局部变量和对象引用已创建并存在于堆栈中。
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, eg 我之所以这样问是因为,当您创建静态变量时,会使用类名来调用它们,例如
Math.round()
When Math class is created, where does it live in memory (heap or stack) 创建Math类时,它在内存中的位置(堆或堆栈)
Gath 迦特
堆的Permgen(永久代)区域...
Java classes lives in Permanent Generation heap
.Also the interned string pool is stored here. Java类位于
Permanent Generation heap
。内部字符串池也存储在此处。
Permanent Generation heap contains: 永久世代堆包含:
类在PermGen空间(即堆)中加载
所有类都加载在PermGen空间中
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 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. 但是请注意,当您调用静态方法时,Java实际上是在幕后创建对象的内部实例,因此您实际上是在对象的“幕后”全局实例上调用该方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.