請幫我通過LinkedHashMap<String,ArrayList<String>> h
創建一個循環:如何通過LinkedHashMap <String,ArrayList <String>>創建一個循環?
if (h.get("key1").size() == 0)
System.out.println("There is no errors in key1.");
else
System.out.println("ERROR: there are unexpected errors in key1.");
if (h.get("key2").size() == 0)
System.out.println("There is no errors in key2.");
else
System.out.println("ERROR: there are unexpected errors in key2.");
if (h.get("key3").size() == 0)
System.out.println("There is no errors in key3.");
else
System.out.println("ERROR: there are unexpected errors in key3.");
if (h.get("key4").size() == 0)
System.out.println("There is no errors in key4.\n");
else
System.out.println("ERROR: there are unexpected errors in key4.\n");
你可以加我的確切消息到您的循環? – Prostak 2011-05-05 18:03:28
@Prostak檢查我的編輯。聽起來就是你想要的。 – 2011-05-05 18:06:19
有點遲了,但是按照插入順序返回還是必須使用迭代器? 'LinkedHashMap'的javadocs和'HashMap'的javadocs相同。 – edthethird 2013-04-11 02:02:53