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("-------------");
                }
            }
            
        }
    }
  • 相关阅读:
    A bon chat, bon rat
    获取信息mysql
    Lua笔记3 表达式
    libevent2编译
    opencv环境搭建
    bash console
    Unix Notes.
    ubuntu vsftpd
    axis2客户端代码生成
    IDEA 快捷键
  • 原文地址:https://www.cnblogs.com/zhengchenhui/p/5568549.html
Copyright © 2011-2022 走看看