Files
roma-dxunvrs 0e6e583e6d
deploy / Pull and Restart (push) Successful in 17s
refactor: wiki links -> md links
2026-09-22 08:52:23 +03:00

46 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Позволяют избегать дублирование кода, помогают обходить [массивы](../Работа%20с%20данными%20и%20типами/Массивы.md)
## С предусловием - while
```Java
int x = 100;
while (x > 0) {
x -= 1;
}
```
## С постусловием - do-while
Всегда выполнится хотя бы один раз
```Java
do {
x -= 1;
} while (x > 0);
```
## Цикл for
Цикл с счетчиком
```Java
for (int i = 0; i < arr.length; i++) {
}
```
Или для прохода по массивам/коллекциям
```Java
for (int num: nums) {
}
```
Для массивов - создает обычный цикл с счетчиком, для коллекций - берет их итератор
## continue и break
break - выходит из текущего цикла, итерация не продолжается
continue - переходит к следующей итерации без завершения текущей
Могут использоваться с метками
```Java
outer:
for (int[] inner: array) {
for (int element: inner) {
if (...) continue;
if (...) continue outer;
if (...) break;
if (...) break outer;
}
}
```
Далее: [Функции](../Работа%20с%20данными%20и%20типами/Функции.md)