方法区:放的是类信息,静态变量,常量...
堆:对象实例和数组
栈:局部变量,也就非静态是方法
package myjava.成员变量和局部变量;
public class Demo {
static int s;
int i;
int j;
{
int i = 1;
i++;
j++;
s++;
}
public void test(int j){
j++;
i++;
s++;
}
public static void main(String[] args) {
Demo demo = new Demo();
Demo demo1 = new Demo();
demo.test(10);
demo.test(20);
demo1.test(10);
System.out.println("demo-------");
System.out.println(demo.i + "-" + demo.j + "-" + s);
System.out.println("demo1-------");
System.out.println(demo1.i + "-" + demo1.j + "-" + s);
}
}