zoukankan      html  css  js  c++  java
  • 数组系列教材 (四)- Java 中如何使用增强for循环

    增强型for循环在遍历一个数组的时候会更加快捷

    步骤1:增强型for循环
    步骤2:练习-最大值
    步骤3:答案-最大值

    步骤 1 : 增强型for循环

    注:增强型for循环只能用来取值,却不能用来修改数组里的值

    public class HelloWorld {

        public static void main(String[] args) {

            int values [] = new int[]{18,62,68,82,65,9};

            //常规遍历

            for (int i = 0; i < values.length; i++) {

                int each = values[i];

                System.out.println(each);

            }

             

            //增强型for循环遍历

            for (int each : values) {

                System.out.println(each);

            }

             

        }

    }


    更多内容,点击了解: https://how2j.cn?p=61135

  • 相关阅读:
    Manjaro中添加gitee的公钥部署
    另类的linux系统
    mac的快捷键flykey应用
    tidb总览
    raft算法
    tidb的tidb
    tidb的tikv
    tidb的pd
    切尔诺贝利事故
    血钻
  • 原文地址:https://www.cnblogs.com/Lanht/p/12615590.html
Copyright © 2011-2022 走看看