Wednesday, January 21, 2009

Eclipse Templates - Iterating Over a Map

Here is another code template. This one, I cannot take the credit for, but I have added it to my toolbox of great Eclipse Templates. It will give you the ability to iterate over a Map using the Map.Entry. Enjoy:

for (Iterator<Map.Entry<${type},${type2}>> it = ${variableName:var(java.util.Map)}.entrySet().iterator(); it.hasNext();) {  
    Map.Entry<${type},${type2}> entry = it.next();  
       ${type} key = entry.getKey();  
       ${type2} value = entry.getValue();  
       // do something with the key and the value  
}

1 comment:

Unknown said...

Thanks for this good stuff. I like your blog very much. Your blog i full of informational content of digital download software. Actually i was searching for logo software download. In urgently i type download sofware. LOL .yeah i know thats funny and i find your blog.