我是靠谱客的博主 虚幻口红,这篇文章主要介绍Java do-while的使用,现在分享给大家,希望可以做个参考。

do-while是while的特殊种类,do-while会先运行一次do里的代码,然后进行while的Boolean判定,然后返回按照do里的方法重新运行。

(先执行,后判断的while loop)

Example:

复制代码
1
2
3
4
5
6
7
8
9
10
11
public 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
11
1 2 3 4 5 6 7 8 9 10 DONE.


最后

以上就是虚幻口红最近收集整理的关于Java do-while的使用的全部内容,更多相关Java内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(61)

评论列表共有 0 条评论

立即
投稿
返回
顶部