Chapter

While Loops

From ComputerScienceOne by Dr Chris Bourke

Concepts

  1. How is a basic while loop structured in Java?

    "Java supports while loops, for loops, and do-while loops using the keywords while, for, and do (along with another while). Continuation conditions for loops are enclosed in parentheses, (...) and the

  2. Why should you avoid a semicolon after a while-loop condition?

    "Consider the following:\n\n1 while(i <= 10);\n\n2 {\n\n3 //perform some action\n\n4 i++; //iteration\n\n5 }\n\nA similar problem occurs: the while keyword and continuation condition bind to the next

  3. How does a flag-controlled while loop work in Java?

    "Another common use case for a while loop is a flag-controlled loop in which we use a Boolean flag rather than an expression to determine if a loop should continue or not. An example can be found in C

While Loops | ComputerScienceOne | Bifalgorithm | Bifalgorithm