2012-02-14 31 views

回答

3
Map<Integer, Integer> map = new HashMap<Integer, Integer>(); 

//java 
for (Map.Entry<Integer, Integer> entry : map.entrySet()) 
{ 
    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); 
} 

//mvel 
foreach (c : map.entrySet) 
{ 

    System.out.println("Key = " +c.key + ", Value = " +c.value); 
} 
+0

不應該在mval表達式中是'c.key'和'c.value'嗎? – Bohemian 2012-02-14 22:19:20

+0

@波希米亞,你是對的。謝謝 – Nomad 2012-02-14 22:34:20

+0

我試過了,我得到一個異常org.mvel2.templates.TemplateRuntimeError:無法迭​​代對象類型:java.util.HashMap – 2012-02-14 22:42:21