while,do while,for循环总结
来源:互联网 发布:购物群软件 编辑:程序博客网 时间:2024/05/16 18:29
- while:先判断,再执行
- for循环:先判断,再执行
- do while :先执行一次,之后再判断
public class Test3 { public static void main(String[] args) { Test3 t=new Test3(); t.test1(); t.test2(); t.test3(); } public void test1() { int i=0; for(;i<0;i++){ int s=0; s+=i; System.out.println(s); } } public void test2() { int i=0; while(i<0){ i++; int s=0; s+=i; System.out.println(s); } } public void test3() { int i=0; do{ i++; int s=0; s+=i; System.out.println(s); }while(i<0); } }
只有test3()方法可以运行一次,结果为1,其他两个方法无法输出结果。
阅读全文
0 0
- C#总结---for,while,do while循环
- while,do while,for循环总结
- while、do while、for循环
- 循环:for、while、do-while
- while循环、do..while 循环、for循环
- for循环,do....while循环,while循环
- for循环,while循环,do while循环
- 循环控制 for while do while switch
- 循环语句小结 for while do-while
- while和do..while和for循环
- while、do...while、for循环的使用
- do... while,while and for 循环
- C#循环while、do...while、for、foreach
- Java 循环结构for、do...while、while
- Java循环for, while和do...while
- Java while,do while, for 循环浅析
- 循环结构语句---for,while,do-while
- java:for while do while循环
- Redis 在Centos7下配置开机自启动
- 补齐函数求数根
- SVN问题-Failed to load JavaHL Library
- PAT (Basic Level) Practise (中文)1003. 我要通过!(20)
- 上传下载
- while,do while,for循环总结
- CSS盒子模型
- angular1项目中bower的使用
- 2017/10/29学习心得
- C和指针之用拉托斯特尼筛方法(Eratosthenes)查找区间质素个数
- debian安装 MariaDB,没有提示输入 root 的密码?
- 为何spring cloud 应该使用 Euraka server 而不是 Zookeeper
- spring和mybatis整合框架
- Macbook svn安装与使用