File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,9 +179,9 @@ public class StringIterationExample {
179179 <program xml : id =" python-countdown" interactive =" activecode" language =" python" >
180180 <code >
181181i = 5
182- while i > 0:
182+ while i > 0: # while i is greater than 0
183183 print(i)
184- i = i - 1
184+ i = i - 1 # decrement i by 1
185185 </code >
186186 </program >
187187
@@ -192,10 +192,10 @@ while i > 0:
192192 <code >
193193public class WhileLoopExample {
194194 public static void main(String[] args) {
195- int i = 5;
196- while (i > 0) {
195+ int i = 5; // initialize i to 5
196+ while (i > 0) { // while i is greater than 0
197197 System.out.println(i);
198- i = i - 1;
198+ i = i - 1; // decrement i by 1
199199 }
200200 }
201201}
@@ -214,10 +214,10 @@ public class WhileLoopExample {
214214 <code >
215215public class DoWhileExample {
216216 public static void main(String[] args) {
217- int i = 10;
218- do {
217+ int i = 10; // initialize i to 10
218+ do { // do-while loop, will run at least once no matter the condition
219219 System.out.println("This runs once, i = " + i);
220- } while (i < 5);
220+ } while (i < 5); // while i is less than 5
221221 }
222222}
223223 </code >
You can’t perform that action at this time.
0 commit comments