java集合map取key使用示例 java遍历map_java

分享到:


for (Iterator i = keys.iterator(); i.hasNext()
       {
           String key = (String) i.next();
           String value = (String) map.get(key);
           text+=key + " = " + value;
       }


<span style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; font-size: 14px; white-space: normal;"><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());
        }

昵    称:
验证码: