我试过了hashmap.values(),不行。
我是这样做的:
Collection ret;
ret= new ArrayList();
ret = hashmap.values();
是错误的,编译都通不过。Collection ret=hashmap.values();也是错误的;

解决方案 »

  1.   

    Object []a=hashmap.entrySet().toArray(); 
    for (int i = 0; i <hashmap.size(); i++) 
    System.out.println(a[i].toString());
      

  2.   

    我HashMap里面放的是两个值,我只想得到后面一个的值,前面只是用来做标志的。用了上面的方法,如何得到后面的数据呢。
      

  3.   

    for (Iterator s_iter=hashmap.values().iterator();s_iter.hasNest()){
       courceInfo s_cInfo = (courceInfo)s_iter.next();
       .......
    }
      

  4.   

    因为HashMap是无续的,所以我们是这样解决这种问题的
    假设你要储的数据为一组
    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));
    就可以得到值了
      

  5.   

    因为,HashMap是Collection的子类,当然应该用iterator来遍历了.
    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);
    }
      

  6.   

    看看Core Java或者TIJ吧,里面说明的很清楚,化点时间是值得的