当前位置:编程学习 > JAVA >>

泛型接口的实现方式之一

inte易做图ce Info<T>{
public T getvar();
}
class Infodemo<T> implements Info<T>{
private T var;
public Infodemo(T var){
this.var = var;
}
public void setVar(T var){
this.var = var;
}
@Override
public T getvar() {
// TODO Auto-generated method stub
return this.var;
}
}
public class Pet{
public static void main(String args[]){
Info<String> var = new Infodemo<String>("李兴华");
System.out.println("内容:"+var.getvar());
}
}

 

补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,