分享Android开发中最有效率最快的循环代码
本文导语: /* 1 ( 最快 ) */ for (int i = initializer; i >= 0; i--) { ... } /* 2 第二 */ int limit = calculateLoopLimit(); for (int i = 0; i < limit; i++) { ... } /* 3 */ Type[] array = getMyArray(); for (Type obj : array) { ... } /* 4 */ for (int i = 0; i < array.length; i++) { ... } /* 5 */ for (int i =...
/* 1 ( 最快 ) */
for (int i = initializer; i >= 0; i--) { ... }
/* 2 第二 */
int limit = calculateLoopLimit();
for (int i = 0; i < limit; i++) { ... }
/* 3 */
Type[] array = getMyArray();
for (Type obj : array) { ... } /* 4 */ for (int i = 0; i < array.length; i++) { ... }
/* 5 */
for (int i = 0; i < this.var; i++) { ... }
/* 6 */
for (int i = 0; i < obj.size(); i++) { ... }
/* 7 (最慢) */
Iterable list = getMyList();
for (Type obj : list) { ... }