From ae147f519a662f1d27d4998a894cb0d669aeb8d3 Mon Sep 17 00:00:00 2001 From: winsonrich <42903383+winsonrich@users.noreply.github.com> Date: Tue, 23 Oct 2018 15:44:25 +0800 Subject: [PATCH] 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. --- guide/chinese/java/loops/break-control-statement/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guide/chinese/java/loops/break-control-statement/index.md b/guide/chinese/java/loops/break-control-statement/index.md index 9a73cac156..af1f2606fb 100644 --- a/guide/chinese/java/loops/break-control-statement/index.md +++ b/guide/chinese/java/loops/break-control-statement/index.md @@ -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) \ No newline at end of file +![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":火箭:") [运行代码](https://repl.it/CJZC/0)