Java Repetition Statements
There are many when you might want to repeat the same code block a number of times. In real life, we do this all the time. For example if you open a bag of jelly beans and eat one them, it’s likely that you will eat another one, possibly as lot more after that! You open the bag once, but then repeat eating an individual jelly bean a number of times – you might stop when you are full or maybe when the bag is empty.
In Java, we use repetition statements to loop through statements within a code block a specific number of times and we have a number of different types of repetition statements that can do this in different ways. In this lesson we will cover:
What you will learn
In this lesson we covered how and why you might use repetition statements in Java. We discussed in detail for loops, while loops, and do while loops. We also discussed variations and explored syntax rules and example code.