Java-For Loop with Multiple Conditions

For Loop with Multiple Conditions The for loop has several capabilities that are not found in other loop constructs. For example, more than one variable can be initialized at a time in the for statement using comma. The test condition may have any compound relation. For example, in the following program, the expression1  has two parts … Read more…

Java-Control Infinite Loop

Control Infinite Loop Using Break If you can force immediate termination of a loop, bypassing the conditional expression and any remaining code in the body of the loop. When a break statement is encountered inside a loop, the loop is terminated and program control resumes at the next statement following the loop. The break statement can be used with … Read more…

Java-Infinite For Loop

Infinite For Loop You can intentionally create an infinite loop, if you leave all three parts of the for empty. The general form is: This loop will run forever because there is no condition under which it will terminate. Although there are some programs, such as operating system command processors, that require an infinite loop, most “infinite … Read more…