public class Test{
int count = 9; //定义成员变量count 进堆
public void count1(){
int count =10; //定义局部成员变量count进栈
System.out.println("count1="+count);
} 局部成员变量count出栈
public void count2(){
System.out.println("count2="+count); //这个count是成员变量
}
public static void main(String args[]){
Test t=new Test();
t.count1();
t.count2();
}
}
|