File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,9 +180,9 @@ public class StringIterationExample {
180180 <program interactive =" activecode" language =" python" >
181181 <code >
182182i = 5
183- while i > 0:
183+ while i > 0: # while i is greater than 0
184184 print(i)
185- i = i - 1
185+ i = i - 1
186186 </code >
187187 </program >
188188 </listing >
@@ -195,10 +195,10 @@ while i > 0:
195195 <code >
196196public class WhileLoopExample {
197197 public static void main(String[] args) {
198- int i = 5;
199- while (i > 0) {
198+ int i = 5;
199+ while (i > 0) { // while i is greater than 0
200200 System.out.println(i);
201- i = i - 1;
201+ i = i - 1;
202202 }
203203 }
204204}
@@ -218,10 +218,10 @@ public class WhileLoopExample {
218218 <code >
219219public class DoWhileExample {
220220 public static void main(String[] args) {
221- int i = 10;
222- do {
221+ int i = 10;
222+ do { // do-while loop, will run at least once no matter the condition
223223 System.out.println("This runs once, i = " + i);
224- } while (i < 5);
224+ } while (i < 5); // while i is less than 5
225225 }
226226}
227227 </code >
You can’t perform that action at this time.
0 commit comments