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 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM