which loop is faster?
Posted
by
Mansuro
on Stack Overflow
See other posts from Stack Overflow
or by Mansuro
Published on 2012-03-19T16:35:38Z
Indexed on
2012/03/19
23:30 UTC
Read the original article
Hit count: 137
java
I have this loop
for (it= someCollection.iterator; it.hasNext(); )
{
//some code here
}
I changed it to:
for (it= someCollection.iterator;; )
{
if (!it.hasNext())
break;
//some code here
}
The second code ran a little bit faster in unit tests in junit on eclipse. Is the second loop faster? I'm asking because the times given by Junit are not too exact, but they give an approximate value
© Stack Overflow or respective owner