Map 的两种遍历方式
方法一HashMap map = new HashMap();map.put("a", "zhangsan");map.put("b", "lisi");map.put("c", "wangwu");System.out.println( map );Set set = map.entrySet();map.values();System.out.println( set );Iterator it = set.iterator();while ( it.hasNext() ) {Entry entry= (Entry) it.next();System.out.println( entry.getKey() +" "+entry.getValue());}//方法二//Set set = map.keySet();//Iterator it = set.iterator();//while( it.hasNext()){//String key = (String) it.next();//System.out.println( map.get(key));//}
?