- /**
- * HashMap的迭代
- * @author Administrator
- *
- */
- public class EntryTest {
- public static void main(String[] args) {
-
- Map<Integer,String> maps = new HashMap<Integer,String>();
-
- maps.put(1, "aa");
- maps.put(2, "bb");
- maps.put(3, "cc");
- maps.put(4, "dd");
-
-
- Set<Map.Entry<Integer,String>> set = maps.entrySet();
-
- for(Map.Entry<Integer, String> entry:set){
- System.out.println(entry.getKey()+"===="+entry.getValue());
- }
-
- Set<Integer> set1= maps.keySet();
- for(Integer i:set1){
- System.out.println(maps.get(i));
- }
- }
- }
复制代码 |
|