泛型-类
2019-06-28 本文已影响0人
建康_木子
泛型
public class TTest <T>{
private T c;
public TTest(T c) {
this.c = c;
}
public T getC() {
return c;
}
public void setC(T c) {
this.c = c;
}
public static void main(String[] args) {
TTest<Dog> dog = new TTest<>(new Dog());
dog.setC(new Dog("dog","black"));
Dog c = dog.getC();
System.out.println(c.getColor());
System.out.println(c.getKind());
}
}