java 接口中使用泛型


 1  interface Info<T>{
2 public T getVar();
3 }
4 class Infolmpl implements info<String>{
5 private String var;
6 public Infolmpl(String Var){
7 this.setVar(var);
8 }
9 public void setVar(String var){
10 this.var=var;
11 }
12 public String getVar(){
13 return this.var;
14 }
15 }
16
17 public class dsadas {
18 public static void main(String args[]){
19 Info<String> i=null;
20 i=new Infolmpl("lixinghua");
21 System.out.println("content:"+i.getVar());
22 }
23 }

在接口中指定類型。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM