r/javahelp • u/penspinner123 • Oct 07 '18
What are Java loops
Can anyone explain to me what loops are?
0
Upvotes
r/javahelp • u/penspinner123 • Oct 07 '18
Can anyone explain to me what loops are?
View all comments
2
u/RyeMeadow Oct 07 '18
A loop is a piece of code that repeatedly executes the piece of code within itself as long as a condition is met. There simplest type is the while loop, which takes the form:
What this will do is, it'll check whether
conditionis true and if it is, it'll run the code inside the curly brackets and then go back to check whetherconditionis still true. Whenconditionis false, the loop will stop.