<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Iterate Map - Dump Map'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Fri, 25 Jul 2008 13:46:06 GMT</pubDate>
<item>
<title>the_coder said on 6/4/08</title>
<link>http://snipplr.com/view/6117/iterate-map--dump-map/</link>
<description><![CDATA[ <p><pre><code>Map<Key,Value> mp;

Iterator<Map.Entry<Key,Value>> it = mp.entrySet().iterator();

while (it.hasNext()) {

    Map.Entry<Key,Value> pair = it.next();

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

}

Map<Key,Value> mp;

for (Map.Entry<Key,Value> pair : mp.entrySet()) {

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

}
</code></pre></p> ]]></description>
<pubDate>Wed, 04 Jun 2008 21:02:12 GMT</pubDate>
<guid>http://snipplr.com/view/6117/iterate-map--dump-map/</guid>
</item>
<item>
<title>the_coder said on 6/4/08</title>
<link>http://snipplr.com/view/6117/iterate-map--dump-map/</link>
<description><![CDATA[ <p>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());
 }</p>

<p>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());
 }</p> ]]></description>
<pubDate>Wed, 04 Jun 2008 21:01:28 GMT</pubDate>
<guid>http://snipplr.com/view/6117/iterate-map--dump-map/</guid>
</item>
<item>
<title>the_coder said on 6/4/08</title>
<link>http://snipplr.com/view/6117/iterate-map--dump-map/</link>
<description><![CDATA[ <p>Map<Key,Value> mp;</p>

<p>Iterator<Map.Entry<Key,Value>> it = mp.entrySet().iterator();</p>

<p>while (it.hasNext()) {</p>

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

System.out.println(pair.getKey() + " = " + pair.getValue());
</code></pre>

<p>}</p>

<p>Map<Key,Value> mp;</p>

<p>for (Map.Entry<Key,Value> pair : mp.entrySet()) {</p>

<pre><code>System.out.println(pair.getKey() + " = " + pair.getValue());
</code></pre>

<p>}</p> ]]></description>
<pubDate>Wed, 04 Jun 2008 21:00:30 GMT</pubDate>
<guid>http://snipplr.com/view/6117/iterate-map--dump-map/</guid>
</item>
<item>
<title>the_coder said on 6/4/08</title>
<link>http://snipplr.com/view/6117/iterate-map--dump-map/</link>
<description><![CDATA[ <p>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]</p>

<p>[code]
Map mp;
for (Map.Entry pair : mp.entrySet()) {
    System.out.println(pair.getKey() + " = " + pair.getValue());
}
[/code]</p> ]]></description>
<pubDate>Wed, 04 Jun 2008 20:58:57 GMT</pubDate>
<guid>http://snipplr.com/view/6117/iterate-map--dump-map/</guid>
</item>
<item>
<title>the_coder said on 6/4/08</title>
<link>http://snipplr.com/view/6117/iterate-map--dump-map/</link>
<description><![CDATA[ <p>Or, with Generics (replace "Key" and "Value" with the actual types of the key and value) in Java 1.5+:</p>

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

<p>Or, combined with the for-each loop in Java 1.5+:</p>

<p>Map mp;
for (Map.Entry pair : mp.entrySet()) {
    System.out.println(pair.getKey() + " = " + pair.getValue());
}</p> ]]></description>
<pubDate>Wed, 04 Jun 2008 20:57:06 GMT</pubDate>
<guid>http://snipplr.com/view/6117/iterate-map--dump-map/</guid>
</item>
<item>
<title>vonkinder said on 5/21/08</title>
<link>http://snipplr.com/view/6117/iterate-map--dump-map/</link>
<description><![CDATA[ <p>To iterate any Map(map, hashMap, etc).</p> ]]></description>
<pubDate>Wed, 21 May 2008 04:34:31 GMT</pubDate>
<guid>http://snipplr.com/view/6117/iterate-map--dump-map/</guid>
</item>
</channel>
</rss>