第二阶段27泛型_泛型类

public class Generic<T> {
    private T flag;

    public void setFlag(T flag){
        this.flag = flag;
    }

    public T getFlag(){
        return this.flag;
    }
}
public class Test1 {
    public static void main(String[]args){
        Generic<String>generic = new Generic<>();
        generic.setFlag("abcdef");
        String flag = generic.getFlag();
        System.out.println(flag);
    }
}

 

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