do-while是while的特殊种类,do-while会先运行一次do里的代码,然后进行while的Boolean判定,然后返回按照do里的方法重新运行。
(先执行,后判断的while loop)
Example:
复制代码
输出为:
1
2
3
4
5
6
7
8
9
10
11public class SimpleDoWhile { public static void main(String[] args) { int index = 1; do { System.out.println(index); index = index + 1; } while(index <= 10); System.out.println("DONE."); } }
复制代码
1
2
3
4
5
6
7
8
9
10
111 2 3 4 5 6 7 8 9 10 DONE.
最后
以上就是虚幻口红最近收集整理的关于Java do-while的使用的全部内容,更多相关Java内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复