Java for loop vs. while loop.性能差异?
2022-09-01 09:08:41
假设我有以下代码,有三个for循环来做一些事情。如果我将最外层的 for 循环更改为 while 循环,它会运行得很快吗?谢谢~~
int length = 200;
int test = 0;
int[] input = new int[10];
for(int i = 1; i <= length; i++) {
for (int j = 0; j <=length - i; j++) {
for (int k = 0; k < length - 1; k++) {
test = test + input[j + k];
}
}
}