class A {
//将父类中的静态成员看作一个全局共享的,被所有的子类共享
public static int a = 10;
public static void fun() {
System.out.println("Hello");
}
}
class B extends A {
public void fun2() {
a = 200;
System.out.println(a);
}
public static void fun() {
System.out.println("World");
}
}
public class ExtendsDemo2 {
public static void main(String[] args) {
B b = new B();
System.out.println(b.a); //10
b.fun(); //World
b.fun2(); //200
System.out.println(b.a); //200
System.out.println(A.a); //200
}
}