提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
遍历HashMap的值
/* nowjava - 时 代 Java 提 供 */ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; public class Main { public static void main(String[] args) { HashMap hMap = new HashMap(); //add key value pairs to HashMap hMap.put("1","One"); hMap.put("2","Two"); hMap.put("3","Three"); Collection c = hMap.values();// 来自 时 代 J a v a - nowjava.com //obtain an Iterator for Collection Iterator itr = c.iterator();