11/8/2005

Iterating over Collections in JDK 1.5

Filed under: Developing — Guus @ 7:28 pm

Iterating over a collection or array in a ugly old manner:

void process(Collection processes) {
for (Iterator
p = processes.iterator(); processes.hasNext();) {
processes.next().process();
}
}

Iterating according to JDK 1.5:

void process(Collection processes) {
for (Process p : processes) {
p.process();
}
}

This very clean !!

Source article

No Comments »

No comments yet.

RSS feed for comments on this post. | TrackBack URI

Leave a comment

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