Java中的内存可分为:栈内存、堆内存和方法区内存
栈内存中主要储存的是方法体当中的局部变量。
堆内存中主要存放的是new运算符创建的java对象和实例变量
方法区内存中主要存放的是方法的代码片段以及整个类的代码片段和静态变量
方法调用时,该方法所需的内存空间在栈内存中分配,称为压栈。
方法结束时,该方法所需的内存空间释放,称为弹栈。