java tutorial - Java Loop While - java programming - learn java - java basics - java for beginners
Learn Java - Java tutorial - Java loop while - Java examples - Javaprograms
The while loop - repeatedly executes the target of the operator as long as the condition is true.
Syntax h2>
- The syntax of the while loop in Java:
- There can be one operator or group of operators. The condition can be any expression, true (true), or any non-zero value.
- When executed, if the result of the logical expression is true, then the actions inside the loop will be executed. This will continue as long as the result of the expression is true.
- When the condition becomes false, the program passes control to the line immediately after the loop.
Process diagram
Learn java - java tutorial - java while loop - java examples - java programs
- The key point of the while loop in Java is that the loop can never be executed.
- When the condition is checked and the result is false, the loop body will be skipped and the first line after the while loop will be executed.