类上带泛型

package com;

public class Box <T>{

    private T t;

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }
    
}

 

public static void main(String[] args) {
        Box<String> s=new Box<String>();
        s.setT("Hello");
        System.out.println(s.getT());;
    }

 

posted on 2017-03-28 17:56  老邱2  阅读(162)  评论(0编辑  收藏  举报

导航