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:

Advertisements

2 Responses to “Java Using new forloop with Hashtable..”

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

  2. Chris Smith said

    “How simpler can it get?” – nothing in Java is simple! Never come across such a hodge-podge of messy rubbish. It takes an entire day to learn how to use dates and times in Java. It is as though the designers sat down and thought about how they could make it as complicated as possible. C# is *much* better. Hands down, if I was starting a new project, then I would use C#. The only reason to use Java is because so much stuff is already written in it. To decide to start a new project in Java is a ridiculous idea. it is too complicated.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: