Concept

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

ComputerScienceOne / While Loops

"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 Code Sample 28.2.\n\n1 int i = 1;\n\n2 boolean flag = true;\n\n3 while(flag) {\n\n4 //perform some action\n\n5 i++; //iteration\n\n6 if(i>10) {\n\n7 flag = false;\n\n8 }\n\n9 }\n\nCode Sample 28.2.: Flag-controlled While Loop in Java"

Related Ideas

How does a flag-controlled while loop work in Java? | ComputerScienceOne | Bifalgorithm | Bifalgorithm