break

Terminates execution of the nearest enclosing do, for, switch, or while statement in which it appears.

 

Compile & Run:

myVar is now: 0
myVar is now: 1
myVar is now: 2
myVar is now: 3

Leave a Reply