<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Comments on snippet: 'Iterate Map - Dump Map'</title>
    <description>Snipplr comments feed</description>
    <link>https://ipv6.snipplr.com/</link>
    <lastBuildDate>Tue, 07 Apr 2026 02:02:00 +0000</lastBuildDate>
    <item>
      <title>vonkinder said on 21/May/2008</title>
      <link>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</link>
      <description>&lt;p&gt;&lt;p&gt;To iterate any Map(map, hashMap, etc).&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 21 May 2008 04:34:31 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</guid>
    </item>
    <item>
      <title>the_coder said on 04/Jun/2008</title>
      <link>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</link>
      <description>&lt;p&gt;&lt;p&gt;Or, with Generics (replace "Key" and "Value" with the actual types of the key and value) in Java 1.5+:&lt;/p&gt;

&lt;p&gt;Map mp;
Iterator it = mp.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry pair = it.next();
    System.out.println(pair.getKey() + " = " + pair.getValue());
}&lt;/p&gt;

&lt;p&gt;Or, combined with the for-each loop in Java 1.5+:&lt;/p&gt;

&lt;p&gt;Map mp;
for (Map.Entry pair : mp.entrySet()) {
    System.out.println(pair.getKey() + " = " + pair.getValue());
}&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 04 Jun 2008 20:57:06 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</guid>
    </item>
    <item>
      <title>the_coder said on 04/Jun/2008</title>
      <link>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</link>
      <description>&lt;p&gt;&lt;p&gt;try again
[code]
Map mp;
Iterator it = mp.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry pair = it.next();
    System.out.println(pair.getKey() + " = " + pair.getValue());
}
[/code]&lt;/p&gt;

&lt;p&gt;[code]
Map mp;
for (Map.Entry pair : mp.entrySet()) {
    System.out.println(pair.getKey() + " = " + pair.getValue());
}
[/code]&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 04 Jun 2008 20:58:57 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</guid>
    </item>
    <item>
      <title>the_coder said on 04/Jun/2008</title>
      <link>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</link>
      <description>&lt;p&gt;&lt;p&gt;Map&lt;Key,Value&gt; mp;&lt;/p&gt;

&lt;p&gt;Iterator&lt;Map.Entry&lt;Key,Value&gt;&gt; it = mp.entrySet().iterator();&lt;/p&gt;

&lt;p&gt;while (it.hasNext()) {&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Map.Entry&amp;lt;Key,Value&amp;gt; pair = it.next();

System.out.println(pair.getKey() + " = " + pair.getValue());
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Map&lt;Key,Value&gt; mp;&lt;/p&gt;

&lt;p&gt;for (Map.Entry&lt;Key,Value&gt; pair : mp.entrySet()) {&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;System.out.println(pair.getKey() + " = " + pair.getValue());
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;}&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 04 Jun 2008 21:00:30 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</guid>
    </item>
    <item>
      <title>the_coder said on 04/Jun/2008</title>
      <link>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</link>
      <description>&lt;p&gt;&lt;p&gt;Okay, got it. Or, with Generics (replace "Key" and "Value" with the actual types of the key and value) in Java 1.5+:
 Map mp;
 Iterator it = mp.entrySet().iterator();
 while (it.hasNext()) {
     Map.Entry pair = it.next();
     System.out.println(pair.getKey() + " = " + pair.getValue());
 }&lt;/p&gt;

&lt;p&gt;Or, combined with the for-each loop in Java 1.5+:
 Map mp;
 for (Map.Entry pair : mp.entrySet()) {
     System.out.println(pair.getKey() + " = " + pair.getValue());
 }&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 04 Jun 2008 21:01:28 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</guid>
    </item>
    <item>
      <title>the_coder said on 04/Jun/2008</title>
      <link>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</link>
      <description>&lt;p&gt;&lt;p&gt;&lt;pre&gt;&lt;code&gt;Map&lt;Key,Value&gt; mp;

Iterator&lt;Map.Entry&lt;Key,Value&gt;&gt; it = mp.entrySet().iterator();

while (it.hasNext()) {

    Map.Entry&lt;Key,Value&gt; pair = it.next();

    System.out.println(pair.getKey() + " = " + pair.getValue());

}

Map&lt;Key,Value&gt; mp;

for (Map.Entry&lt;Key,Value&gt; pair : mp.entrySet()) {

    System.out.println(pair.getKey() + " = " + pair.getValue());

}
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 04 Jun 2008 21:02:12 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/6117/iterate-map--dump-map</guid>
    </item>
  </channel>
</rss>
