Update index.md

1. while the array is larger than the target number of variable:"searchFor" , it is no need to search for the result that is larger than the "search target", therefore, we should break the loop to save more resources.
2. the variable j in the statement of "System.out.println("i = " + j); " is not declare and initialize at the beginning, also, var j in the while loop does not match with the variable i which is the result we want to display. Therefore, this statement should correct to "System.out.println("i = " + i); " so as to display the result of each loop correctly.
pull/27109/head^2
winsonrich 2018-10-23 15:44:25 +08:00 committed by Kristofer Koishigawa
parent 5da9e0bbca
commit ae147f519a
1 changed files with 3 additions and 3 deletions

View File

@ -67,11 +67,11 @@ int i = 0;
int searchFor = 5;
while(i < 10){
System.out.println("i = " + j);
if(arrayOfInts[i] > 7){
System.out.println("i = " + i);
if(arrayOfInts[i] > searchFor){
break;
}
}
```
![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":火箭:") [运行代码](https://repl.it/CJZC/0)
![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":火箭:") [运行代码](https://repl.it/CJZC/0)