Break and Continue

break exits the loop entirely. continue skips to the next iteration.

// Break example:
for (int i = 0; i < 5; i++) {
  if (i == 3) break;
  System.out.println(i);
}

// Continue example:
for (int i = 0; i < 5; i++) {
  if (i == 3) continue;
  System.out.println(i);
}
← PrevNext →