您的位置:首页 > 编程语言 > Java开发

java 设置多个泛型类型

2012-03-14 19:34 465 查看
class NotePad<K,V>{
private K key;
private V value;
public K getKey() {
return key;
}
public void setKey(K key) {
this.key = key;
}
public V getValue() {
return value;
}
public void setValue(V value) {
this.value = value;
}

}

public class dsadas {
public static void main(String args[]){
Notepad<String,Integer> t=new Notepad<String ,Integer>();
t.setKey("李兴华");
t.setValue(30);
System.out.println("Name:"+t.getKey());
System.out.println("Age:"+t.getValue());
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: