首页 > 其他 > 详细

增强for循环

时间:2021-02-28 00:01:36      阅读:22      评论:0      收藏:0      [点我收藏+]
增强for循环

格式:

for(声明语句:表达式){

	//代码

}

    /**
     * @author Administrator
     * @create 2021/2/27 22:46
     */
    public class Demo05 {
        public static void main(String[] args) {
            //定义数组
            int[] num = {10,20,30,40,50};
            //普通for循环 遍历元素
            for (int i = 0; i < num.length; i++) {
                System.out.println(num[i]);
            }
            System.out.println("=====================");
            //增强for循环,遍历数组的元素
            for (int x:num) {
                System.out.println(x);
            }
        }
    }

增强for循环

原文:https://www.cnblogs.com/lilizihaoye/p/14457604.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!