Lesson 12 of 34
break and continue
7 min 25 XP
break stops the loop immediately. continue skips the rest of this round and moves on to the next one.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.To test whether a number is prime, try dividing from 2 upwards and break as soon as you find a divisor.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.