成员变量 在类中的方法外 在堆中 随着类存在 有默认的初始化值,可以直接使用
局部变量 在类中的方法内 在栈中 随着方法的调用存在 没有默认的初始化值,必须先赋值才可以使用
public class test{
public int chengyuan;
public void method(){
int jubu;
chengyuan=100;
System.out.println(chengyuan);
}
public static void main(String[] args) {
test test01=new test();
test01.method();
System.out.println(test01.chengyuan);
}
}