我将所述值转换成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。 –