Java Loops

Sometimes we want a Java program to repeat something over and over again, loops are used to make a program do something more than one time.
Java loops execute a block of commands a specified number of times, until a condition is met.
Java supports following types of loops:
All are slightly different and provides loops for different situations.

Java Loop Control Statements

Loop control statements is used to change normal sequence of execution of loop.
StatementSyntaxDescription
break statementbreak;Is used to terminate loop or switch statements.
continue statementcontinue;Is used to suspend the execution of current loop iteration and transfer control to the loop for the next iteration.
goto statementgoto labelName;labelName: statement;It’s transfer current program execution sequence to some other part of the program.

No comments:

Post a Comment