public class Father{
public static void sayHi(){
System.out.println("hello");
}
}
public class Son{
public static void sayHi(){
System.out.println("world");
}
}
Fahter father = new Father();
Father son = new Son();
Son son1 = new Son();
father.sayHi(); // hello
son.sayHi(); // hello
son1.sayHi(); // world复写方法就是为了达到多态的目的,对于静态方法的“复写”,子类的静态方法并没有办法覆盖父类的,准备来说不叫“复写”了,用谁的引用就会调用谁的方法。语义上没有问题,只是没办法达到多态的效果。