美文网首页
代码练习020

代码练习020

作者: 哈迪斯Java | 来源:发表于2023-04-09 08:03 被阅读0次

    class Toilet<T> {
    public void enter(T t) {

    }
    

    }

    class Male {

    }

    class Female {

    }

    public class Demo {
    public static void main(String[] args) {
    Toilet<Male> mansroom = new Toilet();
    Toilet<Female> womansroom = new Toilet();
    }
    }
    class Entrance<T> {
    public void enter(T t) {
    if(t instanceof Customer) {
    System.out.println("顾客您好,小心地滑");
    }
    }
    }

    class Customer {

    }

    class Staff {

    }

    public class Demo {
    public static void main(String[] args) {
    Staff tom=new Staff();
    Customer mali=new Customer();
    Entrance<Staff> staffEntrance = new Entrance();
    staffEntrance.enter(tom);
    Entrance publicEntrance = new Entrance();
    publicEntrance.enter(tom);
    publicEntrance.enter(mali);
    }
    }

    相关文章

      网友评论

          本文标题:代码练习020

          本文链接:https://www.haomeiwen.com/subject/kmvhddtx.html