堆区:只存放类对象,线程共享;
方法区:又叫静态存储区,存放class文件和静态数据,线程共享;
栈区:存放方法局部变量,基本类型变量区、执行环境上下文、操作指令区,线程不共享;
class A { private String a = “aa”; //a在堆区 public boolean methodB() { String b = “bb”; //b在栈区 final String c = “cc”; // c在栈区 } }
class A { private String a = “aa”; //a在堆区 public boolean methodB() { String b = “bb”; //b在栈区 final String c = “cc”; // c在栈区 } }