Java Loops

Java supports the following three types of loop:

A loop repeatedly executes the same set of instructions till the termination condition is met. As you will see that Java has a loop to fit any programming need.

Java for Loop

A for loop is a repetition control structure which allows you to efficiently write a loop that needs to execute a specific number of times. You will learn more about Java for loop in separate chapter.

Java while Loop

A while loop is a control structure that allows you to repeat a task, certain number of times. You will learn more about Java while loop in separate chapter.

Java do-while Loop

A do-while loop is similar to a while loop, but there is only one difference, i.e., except that a do-while loop is guaranteed to execute at least one time. You will learn more about Java do-while loop in separate chapter.

Java for-each for loop

As of Java 5, the enhanced for loop was introduced. This is mainly used for Arrays. You will learn more about Java for-each for loop in separate chapter.

And, here the below two statements are used to control the loop.

Java break Statement

The break keyword is used to stop the entire loop. You will learn more about Java break statement in separate chapter.

Java continue Statement

The continue keyword can be used in any loop control structures. It causes the loop to directly jump to the next iteration of the loop. You will learn more about Java continue statement in separate chapter.

Examples

Here are some example programs that uses loops:

There are too many example programs that uses loops. Loop is a most important topic of Java or other programming language.

Java Online Test


« Previous Tutorial Next Tutorial »