1 iteratorlai? 来循环
??????1.1
?public static void main(String[] args) {
??// TODO Auto-generated method stub
??Map map = new HashMap();
??map.put("drink", "1");
??map.put("hello", "3");
??map.put("food", "2");
??Iterator iterator = map.keySet().iterator();
??while(iterator.hasNext()){
???System.out.println(map.get(iterator.next()));
??}
}
?
1.2
????? Set entries = map.entrySet( );
??Iterator iterator = entries.iterator( );
??while(iterator.hasNext( )) {
???Map.Entry entry =(Map.Entry)iterator.next();
???Object key = entry.getKey( );
???Object value = entry.getValue();
???System.out.println("Key:"+key);
???System.out.println("/n"+entry); //food=2
??}
???????
?
2 Collections 得到最大最小值
?
??Collection collection = map.values();//返回数值
?
Set sets= map.keySet();
System.out.println(Collections.max(sets));//key的最大值
?
Collection collection = map.values();
System.out.println(Collections.max(collection));//value的最大值