Do-while loop
Цикъл със след условие
Синтаксис:
do
{
statement(s);
} while(condition);
Пример:
class DoWhileLoopExample {
public static void main(String[] args){
int i=10;
do{
System.out.println(i);
i--;
}while(i>1);
}
}Изход:
10
9
8
7
6
5
4
3
2Пример с масив:
Изход:
2 11 45 9
Last updated
Was this helpful?