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.
This commit is contained in:
winsonrich
2018-10-23 15:44:25 +08:00
committed by Kristofer Koishigawa
parent 5da9e0bbca
commit ae147f519a

View File

@ -67,11 +67,11 @@ int i = 0;
int searchFor = 5; int searchFor = 5;
while(i < 10){ while(i < 10){
System.out.println("i = " + j); System.out.println("i = " + i);
if(arrayOfInts[i] > 7){ if(arrayOfInts[i] > searchFor){
break; 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)