1. Overview
1.概述
In this article, we’ll look at a core aspect of the Java language – executing a statement or a group of statements repeatedly using a do-while loop.
在这篇文章中,我们将看看Java语言的一个核心方面–使用do-while循环重复执行一条或一组语句。
2. Do-While Loop
2.Do-While 循环
The do-while loop works just like the while loop except for the fact that the first condition evaluation happens after the first iteration of the loop:
do-while 循环的工作方式与while 循环相同,只是第一个条件的评估发生在循环的第一次迭代之后:。
do {
statement;
} while (Boolean-expression);
Let’s have a look at a simple example:
让我们看一下一个简单的例子。
int i = 0;
do {
System.out.println("Do-While loop: i = " + i++);
} while (i < 5);
3. Conclusion
3.结论
In this quick tutorial, we explored Java’s do-while loop.
在这个快速教程中,我们探讨了Java的do-while循环。
As always, examples can be found over on GitHub.
一如既往,可以在GitHub上找到实例。