我將所述值轉換成HashMap
這樣爲什麼這個HashMap.get返回null?
String group_name[]=group_names.split(",");
String group_ids[]=new_groups.split(",");
Hashtable<Integer,String> hm=new Hashtable<Integer,String>(10);
for(int i=0;i<group_ids.length;i++){
if (group_ids[i]!=null && !group_ids.equals("")) {
hm.put(Integer.parseInt(group_ids[i]), group_name[i]);
}
在下面的代碼列表2
被ArrayList
並且它具有的HashMap
鍵和我正在檢索像下面
for(String group_id1:list2) {
int gid=Integer.parseInt(group_id1);
String group_name=hm.get(Integer.parseInt(group_id1));
這裏的值hm.get()方法返回null
恕我直言,你應該使用HashMap,除非你必須使用Hastable。 –