zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然 JAVA开发学习: 循环结构

    public class Test {
       public static void main(String args[]) {
          int x = 10;
          while( x < 20 ) {
             System.out.print("value of x : " + x );
             x++;
             System.out.print("
    ");
          }
       }
    }

    public class Test {
       public static void main(String args[]){
          int x = 10;
     
          do{
             System.out.print("value of x : " + x );
             x++;
             System.out.print("
    ");
          }while( x < 20 );
       }
    }

    public class Test {
       public static void main(String args[]) {
     
          for(int x = 10; x < 20; x = x+1) {
             System.out.print("value of x : " + x );
             System.out.print("
    ");
          }
       }
    }

    public class Test {
       public static void main(String args[]){
          int [] numbers = {10, 20, 30, 40, 50};
     
          for(int x : numbers ){
             System.out.print( x );
             System.out.print(",");
          }
          System.out.print("
    ");
          String [] names ={"James", "Larry", "Tom", "Lacy"};
          for( String name : names ) {
             System.out.print( name );
             System.out.print(",");
          }
       }
    }

    public class Test {
       public static void main(String args[]) {
          int [] numbers = {10, 20, 30, 40, 50};
     
          for(int x : numbers ) {
             // x 等于 30 时跳出循环
             if( x == 30 ) {
                break;
             }
             System.out.print( x );
             System.out.print("
    ");
          }
       }
    }

    public class Test {
       public static void main(String args[]) {
          int [] numbers = {10, 20, 30, 40, 50};
     
          for(int x : numbers ) {
             if( x == 30 ) {
            continue;
             }
             System.out.print( x );
             System.out.print("
    ");
          }
       }
    }

  • 相关阅读:
    解决html中刷新页面后checkbox还选中的问题
    初始化spring容器的几种方法
    在web.xml中配置spring配置文件的路径
    查找算法
    排序算法
    ORACLE TO_CHAR,TO_DATE函数格式说明
    ORACLE TO_DATE函数
    ORACLE SUBSTR函数
    ORACLE学习笔记
    Linux 查看端口占用情况
  • 原文地址:https://www.cnblogs.com/tszr/p/10960089.html
Copyright © 2011-2022 走看看