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()); }
本博客仅供本人学习、记录,如有错误,恳请指出。欢迎关注公众号:程序员生活