Developer/Designer Notes

Java Using new forloop with Hashtable..

Posted by Kiran Mova on April 5, 2007

How simpler can it get? In the past I always dreaded writing the iterators/enumeration code to loop over the values in a Hashtable. With new for loop syntax in Java 5, I love it!

Hashtable<String, String> myHashtable;

// Creation and initialization code…

//When I want to itereate through values:
for (String val : myHashtable.values() ) {
//do something with val…
}

Like always, there are limitations/nuances to using the new for loop. The following links help understand this java 5 for loop concept better:

One Response to “Java Using new forloop with Hashtable..”

  1. [...] Java Using new forloop with Hashtable.. [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>