摘要: 1 class Info<T,V>{ 2 private T var; 3 private V value; 4 public Info(T var,V value){ 5 this.setVar(var); 6 this.setValue(value); 7 } 8 public T getVar() { 9 return var;10 }11 public void setVar(T var) {12 this.var = var;13 }14 publ... 阅读全文
posted @ 2012-03-14 21:00 谈笑风生膜法师 阅读(2830) 评论(0) 推荐(0)
摘要: 1 class Info<T>{ 2 private T var; 3 public T getVar(){ 4 return var; 5 } 6 public void setVar(T var){ 7 this.var=var; 8 } 9 public String toString(){10 return this.var.toString();11 }12 }13 public class Generics... 阅读全文
posted @ 2012-03-14 20:44 谈笑风生膜法师 阅读(360) 评论(0) 推荐(0)
摘要: 1 class Demo{ 2 public <T> T fun(T t){ 3 return t; 4 } 5 } 6 public class GenericsDemo { 7 public static void main(String[] args) { 8 Demo d=new Demo(); 9 String str=d.fun("hsjkdka");10 int i=d.fun(30);11 System.out.println(str);12 System.... 阅读全文
posted @ 2012-03-14 20:21 谈笑风生膜法师 阅读(3678) 评论(0) 推荐(0)
摘要: 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(){... 阅读全文
posted @ 2012-03-14 20:20 谈笑风生膜法师 阅读(7015) 评论(0) 推荐(0)
摘要: 1 class NotePad<K,V>{ 2 private K key; 3 private V value; 4 public K getKey() { 5 return key; 6 } 7 public void setKey(K key) { 8 this.key = key; 9 }10 public V getValue() {11 return value;12 }13 public void setValue(V value) {14 ... 阅读全文
posted @ 2012-03-14 19:34 谈笑风生膜法师 阅读(7704) 评论(0) 推荐(0)