/**
 * java Static Dispatch 
 * java The compiler is in overload The static type of the parameter instead of the actual type is used as the basis of the fragment , And static types are known at compile time .
 *  Static dispatch is sent in the compile phase .
 * @author idea-pcfff
 *
 */
public class StaticDispatch {
    static abstract class Human{
        
    }
    static class Man extends Human{
        
    }
    static class Woman extends Human{
        
    }
    public void sayHello(Human h){
//        if(h instanceof Woman){
//            sayHello((Woman) h);
//        }
//        else if(h instanceof Man){
//            sayHello((Man) h);
//        }else{
            System.out.println("hello h");
        //}
    }
    public void sayHello(Man m){
        System.out.println("hello m");
    }
    public void sayHello(Woman w){
        System.out.println("hello w");
    }
    public static void main(String[] args) {
        Human man = new Man();
        Human woman = new Woman();
        StaticDispatch sd  = new StaticDispatch();
        
        sd.sayHello(man);
        // hello h
        sd.sayHello(woman);
        // hello h
    }

}