java聚集map取key應用示例 java遍歷map。本站提示廣大學習愛好者:(java聚集map取key應用示例 java遍歷map)文章只能為提供參考,不一定能成為您想要的結果。以下是java聚集map取key應用示例 java遍歷map正文
for (Iterator i = keys.iterator(); i.hasNext()
{
String key = (String) i.next();
String value = (String) map.get(key);
text+=key + " = " + value;
}
<span ><pre class="lang-java prettyprint"><span>
</span></pre>
</span>
或許
or (Map.Entry<String,String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
// do stuff
} Iterator<Entry<String, String>> iterator = map.entrySet().iterator();
Entry< String, String> entry;
while(iterator.hasNext()){
entry = iterator.next();
Log.d("Key Value",entry.getKey()+" "+entry.getValue());
}