权限修饰符
finall
static
静态成员方法只能访问静态成员
class Student {
public String name; //姓名
public int age; //年龄
public static String university; //学校 共享数据!所以设计为静态!
public void show() {
System.out.println(name + "," + age + "," + university);
}
}
public class StaticDemo {
public static void main(String[] args) {
// 为对象的共享数据赋值
Student.university = "传智大学";
Student s1 = new Student();
s1.name = "林青霞";
s1.age = 30;
s1.show();
}
}