Learn Fundamentals of Java Programming “Repetition Structures in Java Programming ” Lesson 11
Repetition Structures
In real life you often do something repeatedly, for example, consider a task such as reading a book, first you open the book, and then repeatedly – read a page; flip the page – until you get to the end of the book, then close the book.
Similarly, when writing programs, you might need to perform the same sequence of statements repeatedly until some condition is met. The ability of a computer to perform the same set of actions again and again is called looping. The sequence of statements that is repeated again and again is called the body of the loop. The test conditions that determine whether a loop is entered or exited is constructed using relational and logical operators. A single pass through the loop is called an iteration. For example, a loop that repeats the execution of the body three times goes through Java provides three statements – the while statement, the do while statement, and the for statement for looping.