Java: Do/While Loop

int i = 0;
do {
  System.out.println(i);
  i++;
}
while (i < 5);

// Outputs
0
1
2
3
4

At least it will invoke 1 time the code inside of "do"

int i = 0;
do {
   System.out.println(i);
   i++;
}
while (i < 1); 

// Outputs
0

 

posted @ 2022-11-24 03:57  小白冲冲  阅读(16)  评论(0编辑  收藏  举报