一
HashMap staff = new HashMap();
添加關鍵字值對
Set entries = staff
Iterator iter = entries
while(iter
{
Map
Object key = entry
Object value = entry
}
二
Map map = new HashMap();
for (Iterator iter = map
Map
Object key = entry
Object val = entry
}
三
Map map = new HashMap();
for (Iterator iter = map
Object key = iter
Object val = map
}
Iterator是迭代器
對於keySet其實是遍歷了
而entryset只是遍歷了第一次
對於我們做web的
hashmap使用很多
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19815.html