public class VarDemo {
int z;
static int zz;
public void method1(){
System.out.println("this is:"+z);//输出this is 0
System.out.println("this is:"+zz);//输出this is 0
}
public static void main(String[] args) {
System.out.println(z);//报错未解决的编译问题:无法对非静态字段Z进行静态引用
System.out.println(zz);//输出0
z=6;//报错
zz=8;//可以
VarDemo vd=new VarDemo();
vd.method1();
}
}