Thinking in java学习笔记之迭代器

  Map<String,String> map = new HashMap<String,String>();
       List list = new ArrayList();
       list.add("565");
       map.put("key", "value");
       Iterator it =map.keySet().iterator();
       while(it.hasNext()){
           String a=(String) it.next();
           System.out.println(map.get(a));
       }
       Iterator its = list.iterator();
       while(its.hasNext()){
           System.out.println(its.next());
       }

 

posted @ 2016-11-19 13:20  yansum  阅读(109)  评论(0编辑  收藏  举报