Map<String, String> map = new HashMap<String, String>();
map.put("AA", "aa");
map.put("BB", "bb");
map.put("CC", "cc");
map.put("DD", "dd");
// 返回此映射中包含的映射关系的 Set集合
Set<Entry<String, String>> set = map.entrySet();
for(Entry<String, String> entry: set)
{
//每个Entry就是map中一个key及其它对应的value被重新封装的对象
System.out.println(entry.getKey() + " " + entry.getValue());
}
// 运行结果
// AA aa
// BB bb
// CC cc
// DD dd
<pre name="code" class="java">Iterator iter = mapActivity.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();