To summarize: use the enhanced for loop by default, but consider a hand-written counted loop for performance-critical ArrayList iteration.
结论:优先采用改进for循环,但在性能要求苛刻的ArrayList迭代中,考虑采用手写计数循环。
The enhanced for loop (also sometimes known as "for-each" loop) can be used for collections that implement the Iterable interface and for arrays.
改进for循环(有时被称为“for - each”循环)能够用于实现了iterable接口的集合类及数组中。
The enhanced for loop, sometimes called the for-each loop, is translated by the compiler as if the programmer had supplied the equivalent old-style for loop.
增强的for循环有时叫做for - each循环,编译器编译它的时候,情形与程序员提供旧式for循环一样。
应用推荐