首页 > 其他分享 >while 与do while的区别

while 与do while的区别

时间:2023-12-26 17:58:39浏览次数:22  
标签:do 区别 ++ System while println out

do....while 与while 的区别

while 先判断后执行,do while是先执行后判断

do while 总是保证循环体会被至少执行一次

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);
  }
 

标签:do,区别,++,System,while,println,out
From: https://www.cnblogs.com/huangjiangfei/p/17928936.html

相关文章

  • Windows事件日志
    本文主旨:了解Windows事件日志的相关信息,以便于后续进行Windows日志分析。事件日志简介事件日志记录[1]为(的应用程序和操作系统)记录重要软件和硬件事件提供了一种标准的集中式方法。事件日志记录服务记录来自各种源的事件,并将其存储在名为事件日志的单个集合中。事件日志......
  • M1 Docker 部署rocketmq
    1、克隆镜像arm64镜像代码编译镜像,docker直接安装会报错所以选择编译gitclonehttps://github.com/apache/rocketmq-docker.git  cdrocketmq-docker #注意这里centos固定不要改镜像版本可以改shbuild-image.sh4.8.0centos 第二步:拉取mqconsole镜像: candice0630/rocket......
  • Docker 运行命令
    停止所有的容器dockerstop$(dockerps-aq)启动所有的容器dockerstart$(dockerps-aq)停止容器dockerstop<容器Name>启动容器dockerstart<容器Name>删除所有的容器dockerrm-f$(dockerps-aq)删除所有的镜像docker-composedown--rmiall删除容器docke......
  • How can I do to protect the Environmental
    HowcanIdotoprotecttheEnvironmental  Protectingtheenvironmentisanimportantresponsibilitythatweallshare.Herearesomesimplestepsyoucantaketohelpprotecttheenvironmentandreduceyourimpactontheplanet:  Reduce,reuse,andrecyc......
  • What do you think of Crazy Shopping on Novermber?
    WhatdoyouthinkofCrazyShoppingonNovermber? AsanAIlanguagemodel,IdonothavepersonalopinionsorfeelingsaboutshoppingonNovemberoranyothertimeoftheyear.However,Icanprovidesomegeneralinformationandtipsaboutshoppingduring......
  • What do you think of Online and Classroom Class advantages and disadvantages?
    WhatdoyouthinkofOnlineandClassroomClassadvantagesanddisadvantages? Onlineandclassroomclasseseachhavetheirownsetofadvantagesanddisadvantages,whichcanmakethemmoreorlesssuitablefordifferentstudentsandlearningsituations.Ad......
  • Do cars need smart devices?
    Smartdevicesarebecomingincreasinglycommoninmoderncars,andtheycanprovideseveralbenefitsfordrivers.However,whetherornotcarsneedsmartdevicesisamatterofpersonalpreferenceanddependsonindividualneedsandpriorities. Smartdevi......
  • python中for循环跟while循环的对比(加深记忆)
    while循环和for循环的对比 通过对比更能理解循环在循环控制上:    whlie循环可以自定循环条件,并自行控制    for循环不可以自定循环条件,只可以一个个从容器内取出数据在无限循环上:     while循环可以通过条件控制做到无限循环      fo......
  • Windows下用rclone代替RaiDrive将ftp映射为本地盘
    Windows下用rclone代替RaiDrive将ftp映射为本地盘1.软件准备:nssm:官网下载地址:https://nssm.cc/downloadrclone:官网下载地址:https://rclone.org/downloads/WinFsp:官网下载地址:https://winfsp.dev/rel/2.使用:下载WinFsp,如我下载的是winfsp-2.0.23075.msi,下一步下......
  • Thoughts and ideas about how to apply LLMs in specific domains like clinic/law/f
    ApplyingLLMsinSpecificDomainsAsauniversitystudentwhohasjustcompletedfine-tuningTinyLLaMA-1bwithclinicalinstructiondatausingtheQLoRAmethodandevaluateditontheMedMCQAdataset,Ihavegatheredsomeinsightsandideasonhowtoappl......