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