zoukankan      html  css  js  c++  java
  • [java基础]循环结构1

    [java基础]循环结构1

    循环结构:for循环,while循环,do_while循环在,增强型for循环

    /**
    文件路径:G:JavaByHands循环语句
    文件名称:WhileTest.java
    编写时间:2016/6/7
    作    者:郑晨辉
    编写说明:while do while 代码示例
    */
    
    public class WhileTest{
        public static void main(String[] args){
            //初始条件
            int i  = 0;
            //进入循环,while循环先判断再操作条件
            while (i < 5) {
                //输出语句
                System.out.println(i + "< 5");
                //操控条件
                i ++;
            }
            System.out.println(i);
            
            //do while
            //初始化条件
            int j = 0;
            //进入循环do while循环先操作条件再判断
            do {
                System.out.println(j + "<5");
                j++;
            }
            while (j < 5);
            System.out.println(j);
            
        }
    }
    /**
    文件路径:G:JavaByHands循环语句
    文件名称:ForTest.java
    编写时间:2016/6/7
    作    者:郑晨辉
    编写说明:for循环代码示例
    */
    
    public class ForTest{
        
        public static void main(String[] args){
            //最基础的for循环
            for(int i = 0;i < 5; i ++) {
                System.out.println(i);
            }
            
            //循环嵌套
            //第一层
            for(int j = 0;j < 5; j ++) {
                //第二层
                for(int k = 0;k < 3; k ++) {
                    System.out.println("j的值是:" + j);
                    System.out.println("K的值是:" + k);
                    System.out.println("-------------");
                }
            }
            
        }
    }
  • 相关阅读:
    NTP服务器搭建
    Linux安装MongoDB 4.4.2
    CentOS安装Zookeeper 3.6.2
    CentOS安装Redis 6.0.9
    MacBook Home End
    SLES Install
    cucumber soapui test web services
    S/4 HANA Solution Manager
    Linux下创建新用户
    su with hyphen and without
  • 原文地址:https://www.cnblogs.com/zhengchenhui/p/5568549.html
Copyright © 2011-2022 走看看