Where are Java static variables stored in memory?

class A{
class A{
 static int i = 10;
 static int j = 20;

 static void getname(){

   }

}

Where are these variables stored in memory?

Solution

In short, static variables are stored in heap The class and all data applied to the class (not instance data) are stored in the "permanent generation" section of the heap

If you need detailed answers, please refer to

static allocation in java – heap,stack and permanent generation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>