Witscale Test Center

5.3 Iterative statements while, do-while and for


5.3 Iterative statements while, do-while and for

Looping is the repetitive execution of code. It is also called iteration. Java provides three loop constructs, while(), do-while() and for(). Each provides a facility to repetitively execute a block of code. The while and do-while iterate as long as a certain condition is true. On the other hand, the for loop iterates only for a specific number of times. Let us discuss the simplest of all, the while loop first.