第二阶段32-泛型_无界通配符

public class Generic1<T> {

    private T name;

    public void get(T name){
        this.name = name;
    }

    public T show(){
        return this.name;
    }
}
public class get {
    public void plasiy(Generic1<?>generic1){
        System.out.println(generic1.show());
    }
}
public class Test5 {
    public static void main(String[]args){
        get p = new get();
        Generic1<Integer> generic1 = new Generic1<>();
        generic1.get(34);
        p.plasiy(generic1);

        Generic1<String> generic2 = new Generic1<>();
        generic2.get("safkk");
        p.plasiy(generic2);
    }
}

 

posted @ 2022-01-18 21:50  iiuu也一样  阅读(31)  评论(0编辑  收藏  举报