Use a for-loop or a for-each loop? [closed]
Closed . This question is opinion-based. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed 6 years ago . Should we prefer the for-each loop instead of the traditional for-loops? Is the while-loop advantageous? List<String> names = Arrays.asList("John", "Jeff", "Mary", "Elise"); //for-each loop for(String name: names){ log(name); } //traditional for-loop for(int index=0; index < 10; ++index){ log(names.get(index)); } //Iterator while Iterator<String> iter1 = names