class Person{
String name;
int age;
static int eyeNum;
public void info(){
System.out.println("我的名字是:" + name + ",年龄是:" + age);
}
}
public class FieldTest{
public static void main(String[] args){
Person.eyeNum = 2;
System.out.println("1、通过Person类访问eyeNum类变量:" + Person.eyeNum);
Person p = new Person();
p.name = "张三";
p.age = 20;
p.eyeNum = 3;
System.out.println("2、通过p变量访问Person类的eyeNum类变量:" + p.eyeNum);
p.info();
}
}