2013-07-25 105 views
0

我需要添加元素到散列表,我的散列表需要有一個數組列表。但我無法找到正確添加表格中元素的方法。請幫助我。static Hashtable <Leader,ArrayList <Integer>> assignedLeader = new Hashtable <Leader,ArrayList <Integer>>(20);

static Hashtable<Integer, ArrayList<Integer>> assignedLeader = 
    new Hashtable<Integer, ArrayList<Integer>>(20); 
+1

我們可以看到您到目前爲止嘗試過的代碼嗎? – Lochemage

+0

我嘗試了很多,但都給了錯誤,所以沒有用這裏寫錯誤代碼 –

+0

如果您打算在單線程應用程序中使用此代碼,請使用HashMap而不是Hashtable – user2506840

回答

1

只是供您參考。

static Hashtable<Integer, ArrayList<Integer>> assignedLeader = 
      new Hashtable<Integer, ArrayList<Integer>>(20); 

    ArrayList<Integer> al=new ArrayList<Integer>(); 
    al.add(1); 
    al.add(2); 
    al.add(3); 

    assignedLeader.put(1, al); 
相關問題