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:
Java Hashmap or Hashtable « Web Pensieve - Developer’s Journal said
[...] Java Using new forloop with Hashtable.. [...]