java 设置多个泛型类型
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 this.value = value;
15 }
16
17
18 }
19
20 public class dsadas {
21 public static void main(String args[]){
22 Notepad<String,Integer> t=new Notepad<String ,Integer>();
23 t.setKey("李兴华");
24 t.setValue(30);
25 System.out.println("Name:"+t.getKey());
26 System.out.println("Age:"+t.getValue());
27 }
28 }