zoukankan      html  css  js  c++  java
  • 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整除的整数。

  • 相关阅读:
    Http与WWW服务精解
    Http与WWW服务精解
    6-13
    好用的工具说明
    JVM、JRE和JDK三者间的区别和联系
    css进阶之二:flex弹性布局
    MVVM
    如何理解TCP的三次握手协议?
    java里面的设计模式
    linux常用命令
  • 原文地址:https://www.cnblogs.com/Ly426/p/4717818.html
Copyright © 2011-2022 走看看