代码练习020

2023-04-09  本文已影响0人  哈迪斯Java

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);
}
}

上一篇下一篇

猜你喜欢

热点阅读