Java View all facts Glossary Help |
syntactic unit > statement > control flow statement > loop statement |
loop statement comparison table |
Subject | have example | have syntax | have disadvantage | have purpose | has part | interchange with | have advantage |
---|---|---|---|---|---|---|---|
do-while loop | int c; | for (entry expression; boolean expression; continuation expression) { | to execute a section of code more than once | ||||
for loop | a is an array of some kind | for(initializer; condition; incrementer) | it can be slightly harder to read the code of a for loop than a while loop | to execute a section of code more than once | initializer | a while loop | all the information about controlling the loop is kept in one place |
while loop | //Decrement n by 1 until n is 0 | while(condition) | to repeat a computation by looping through that computation until a test has been satisfied | a for loop |
Next control flow statement: return statement Up: control flow statement Previous control flow statement: label statement