我试过了hashmap.values(),不行。
我是这样做的:
Collection ret;
ret= new ArrayList();
ret = hashmap.values();
是错误的,编译都通不过。Collection ret=hashmap.values();也是错误的;
我是这样做的:
Collection ret;
ret= new ArrayList();
ret = hashmap.values();
是错误的,编译都通不过。Collection ret=hashmap.values();也是错误的;
for (int i = 0; i <hashmap.size(); i++)
System.out.println(a[i].toString());
courceInfo s_cInfo = (courceInfo)s_iter.next();
.......
}
假设你要储的数据为一组
name 和value
首先:建一个
ArrayList al=new ArrayList();
把name按你想要的顺序放到al里,
然后在把name和value放到HashMap里,
HashMap hm=new HashMap();
hm.put(name,value);
然后根据al里的值,就可以读出hm里的值了,这样得出的数据是有序的,而且可以随便读取
hm.get(al.get(0));
就可以得到值了
HashMap map=new HashMap();
map.put("xx","xxxx");
......
......
Iterator it=map.keySet().iterator();
while (it.hasNext())
{
Object obj=map.get(it.next());
System.out.println(obj);
}