Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Big Fat Disclaimer</strong>: this is not really an answer (maybe). I don't know about this topic beyond what I've read. I'd rather post this as a comment, but the size limitation and formatting features makes an answer a better, constructive, alternative. I don't understand this subject enough to answer, and I'm helping the research only.</p> <p>On the <a href="http://developer.android.com/guide/practices/design/performance.html#foreach" rel="nofollow noreferrer">Android dev guide</a>:</p> <blockquote> <p><strong>With an ArrayList, a hand-written counted loop is about 3x faster</strong> (with or without JIT), but for other collections the enhanced for loop syntax will be exactly equivalent to explicit iterator usage.</p> </blockquote> <p><a href="https://stackoverflow.com/questions/716597/array-or-list-in-java-which-is-faster/717205#717205">Here</a>, a user benchmarked a for-each loop:</p> <blockquote> <p>n.b. I did notice that using for String s: stringsList was about 50% slower than using an old-style for-loop to access the list. Go figure... Here's the two functions I timed; the array and list were filled with 5000 random (different) strings.</p> </blockquote> <p>Below, another user warns about benchmarks. Personally, I doubt the use of a for loop would create such a problem on your code, as I've been wary of micro-benchmarking in Java. For what I've seen, it all boils down to microseconds of the Iterator object running. I believe you're doing something wrong, as just because you removed the enhanced for and it performed better doesn't imply that the enhanced for itself is slow or bad.</p> <p><a href="https://stackoverflow.com/questions/6839494/enhanced-for-loop-performance-worse-than-traditional-indexed-lookup">On another topic</a>:</p> <blockquote> <p><strong>TL;DR</strong>: enhanced loops are indeed slower than a traditional index-based loop over an arraylist; but for most applications the difference should be negligible.</p> </blockquote> <p><a href="http://today.java.net/article/2006/11/03/nuances-java-50-each-loop" rel="nofollow noreferrer">See a doc</a> about the enhanced for loop. You shouldn't be changing the list at will while in the loop. If that relates to your problem, I don't know. Perhaps maybe if I see the code and log lines.</p> <p>So, I'd guess you're doing something wrong on your code. :-) But it would be better to wait until experienced people come up here.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload