Do whlie 循环

◆对于while语句而言,如果不满足条件,则不能进入循环。但有时候我们需要即使不满足条件,也至少执行-次。

◆do...while循环和while循环相似,不同的是,do...while 循环至少会执行一次。

do {

//代码语句

}while(布尔表达式);

◆While和do-While的区别:

◆while先判断后执行。dowhile是 先执行后判断!

◆Do...while总是保证循环体会被至少执行一次! 这是他们的主要差别。

package com.jiemo.struct;
public class DowhileShabi1 {  
   public static void main(String[] args) {        
       int i= 0;        
       int sum =0;        
       do {            
           sum=sum+i;            
           i++;        
      }while (i<=100);        
       System.out.println(sum);   }}
package com.jiemo.struct;
public class DowhileShabi2 {    
   public static void main(String[] args) {        
       int a = 0;        
       while (a<0){        
           System.out.println(a);        
           a++;   }        System.out.println("_____________________________________________________-");      
       do {            
           System.out.println(a);            
           a++;        
      }while (a<0);   }}

最新文章

  1. SqlServer游标简介
  2. MVC学习笔记----缓存
  3. 批处理脚本为Mysql重置root密码(重置密码为123456)
  4. sqlserver 解析Json字符串
  5. Windows 10 Weather App无法正常显示解决方法
  6. VC2005从开发MFC ActiveX ocx控件到发布到.net网站的全部过程
  7. Linux高级字符设备驱动
  8. 【NGUI】屏幕自适应(不用UIStretch,用UIRoot)---------------good
  9. FastDFS配置过程
  10. How to hide TabPage from TabControl
  11. (转)JQuery处理json与ajax返回JSON实例
  12. Commons Beanutils使用setProperty() - 就是爱Java
  13. poj2262
  14. 基于visual Studio2013解决C语言竞赛题之0514单词统计
  15. MyBatis3入门
  16. 【C++笔记】析构函数(destructor)
  17. Luogu P1967 货车运输
  18. BZOJ.4738.[清华集训2016]汽水(点分治 分数规划)
  19. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习2
  20. 【大数据】Hive学习笔记

热门文章

  1. DELL品牌电脑开机显示supportASsiSt丨pre-Boot SyStem Proforman?
  2. darkriscv笔记
  3. 92、kkfile打印当前页
  4. redis之缓存穿透、缓存击穿、缓存雪崩
  5. python 发送 application/x-www-form-urlencoded 类型的数据包
  6. OSS管理文件(Java)
  7. Unity生成AB包和加载AB包
  8. 【Windows】查询端口占用并中止进程
  9. heap 算法函数
  10. docker部署服务器