Their use is so ubiquitous as to defy the imagination. Any time you want to count out anything, programmatically, you'll probably be using a for loop. If you go through some of the sun tutorials, you will find a page where you can download the sample code from the tutorial. If you open any one of these code files I'll bet you will have a 50% or greater chance of finding a for loop. I'd study these.
Give each player a turn.
Keep getting user input until user enters "quit."
Read each line in a file.
Keep processing chat messages until user signs off.
List out each student's name and grade.
Compute the average of a bunch of values.
...and so on and so on and so on.
Any time you're performing the same operations on different data, or repeating something until some stopping condition, you're using a loop.
You use loops every day in your real life.
You keep taking another step until you get to your classroom.
You keep drinking until that bottle of beer is empty, and you keep getting new bottles until the fridge is empty. (That's a nested loop.)
You keep hitting channel-up until you find a show you like.
... and so on and so on and so on.
> > You use loops every day in your real life.
>
> I don't. Divine people like me use tail recursion.
> Loops are for peasants. ;-)
>
> kind regards,
>
> J(o(s))
void drinkRemainingGrolsch(List<Grolsch> precious) {
if (precious.isEmpty()) {
precious.restock();
}
drink(precious.get(0));
drinkRemainingGrolsch(precious.subList(1,precious.size()));
}