Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 511 Bytes

empty_expressions.md

File metadata and controls

35 lines (31 loc) · 511 Bytes

Empty Expressions

You are also allowed to leave the expression part of a for loop blank.

~void main() {
for (int i = 0;;i++) {
    System.out.println(i);
}
// 0
// 1
// 2
// 3
// ... and so on
~}

This means that each time through there is no check to see if the loop will exit. The loop will only exit if there is an explicit break somewhere.

~void main() {
for (int i = 0;;i++) {
    if (i == 5) {
        break;
    }
    System.out.println(i);
}
// 0
// 1
// 2
// 3
// 4
~}