- Loops make the computer do the same thing over and over again until a certain goal is achieved.
- Loops are helpful because they make things faster, prevent mistakes, and make the code easier to understand.
- The Java while loop makes a part of the program repeat over and over again until a specific condition is met. The loop stops as soon as the condition is not true anymore.
- The while loop is like a repeat button for an if statement. If you don't know how many times to do something, use the while loop.
Syntax ->
while (condition) {
// code
}
Here are some examples of while loop to help you understand better.
No comments:
Post a Comment