for循环
for (int i = 0; i <= 10; i++) {
print(i);
}
for in
for (int i = 0; i <= 10; i++) {
print(i);
}
while
List people = ['tom', 'ant', 'jeson'];
int i = 0;
while (i < people.length) {
print(people[i]);
i++;
}
do whild
List people = ['tom', 'ant', 'jeson'];
int i = 0;
do {
print(people[i]);
i++;
} while (i < people.length);
break关键字
for (int i = 0; i <= 10; i++) {
if (i == 4) {
break;
}
print(i);
}
指定停止某个循环
outLoop:
for (int i = 0; i < 3; i++) {
innerLoop:
for (int j = 0; j < 3; j++) {
if (i == 2) {
break innerLoop;
}
print('$i $j');
}
}
continue 停止本次循环
for (int i = 0; i < 3; i++) {
if (i == 1) {
continue;
}
print(i);
}