HashMap的values返回一个Collection,java.util.TreeSet(java.util.Collection) 
java.util.HashSet(java.util.Collection) 

解决方案 »

  1.   

    HashMap的values返回一个Collection,java.util.TreeSet(java.util.Collection) 
    java.util.HashSet(java.util.Collection) 
      

  2.   

    这个简单 
    HashMap hm = new HashMap();
    hm.put("a", new Integer(1));
    hm.put("b", new Integer(2));
    hm.put("c", new Integer(3));
    hm.put("d", new Integer(4));
    hm.put("e", new Integer(5));Set   set =hm.entrySet(); //这句话就是把一个Map转换成一个set,
                              //set中的每个元素都是实现了Map.Entry借口的对象
    System.out.println("entrySet:" + set);

    Iterator i = set.iterator();
    while(i.hasNext()){
    Map.Entry me = (Map.Entry)i.next();
    System.out.println("key=" +me.getKey());
    System.out.println("value==" +me.getValue());
    }
      

  3.   

    public class testCollection {
    public static void main(String[] args) {

    testCollection tc=new testCollection();  
            Set sets=tc.getParamers();
           
           Iterator it=sets.iterator();
          
           while(it.hasNext()){
            
            Map.Entry map=(Map.Entry)it.next();
            System.out.println("key="+map.getKey());
     System.out.println("value="+map.getValue());  
          }   
     
    }

         public  Set getAdapter(){
      Map map=new HashMap();
      map.put("1","test01");
      map.put("2","test02");
               //这一句就是将map里的内容转换为set(格式{{1,test01},{2,test02},.....})
         Set set=map.entrySet();
         return set;
       
       }
    }