• Java小程序2(2015-8-10)


    /*
    while语句的使用、讲解
    */
    public class Test1{
     public static void main(String[] args){
      int number = 10;
      //--循环条件
      while(number>0){
       //--循环体:循环执行的语句
       System.out.println(number);
       //--条件的变化
       number--;
      } 
     }
    }

    /* do-while的讲解使用 */ public class Test2{  public static void main(String[] args){   int number = 10;

      do{    System.out.println(number);

       number--;

      }while(false);

      while(false){    //==循环体   }

     } }

    1、使用do-while单循环,打印输出10~100之间所有

    public class Test22{      

    public static void main(String [] args){                     

                  System.out.println("10-100之间能同时被5和9整除的整数有:");

                  int a=10;         

       do{                

                   if(a%5==0&&a%9==0){              

                                 System.out.println(a);}                                  

                                 a++;

               }while(a<=100);            

                /*  System.out.println("10-100之间能同时被5和9整除的整数有:");

                int a=10;          

                 while(a<=100)           {               

                             if(a%5==0&&a%9==0){             

                                              System.out.println(a);}                                

                              a++;

               }*/

      }}

    能同时被5和9整除的整数。

  • 相关阅读:
    正则表达式
    公司培训文档混淆的基本概念
    堆和栈的区别[导入]
    一個textlist控件(左右兩個文本框)。
    深入浅出之正则表达式(一)
    公司培训文档-c#基础学习
    问题
    [转]CStdioFile中文问题
    VB用户控件制作讲解与实例用户控件属性或函数的描述信息如何写入程序
    什么是表驱动
  • 原文地址:https://www.cnblogs.com/Ly426/p/4717818.html
Copyright © 2020-2023  润新知