增强for循环

增强for循环:


package com.cheng.struct;

public class IfDemo01 {
   public static void main(String[] args) {
       //增强for循环
       int[] numbers = {10,20,30,40,50};
       for(int x:numbers){  //必须是int x 即新的声明 不能提前声明然后在此处用
           System.out.print(x+"\t");
      }
  }
}

 

posted @ 2021-05-25 20:10  Dudo1  阅读(43)  评论(0)    收藏  举报