290114lyp

导航

增强for循环

增强for循环

for(声明语句:表达式)

{

//代码句子

}

package com.jiemo.struct;
public class ForShabi5 {    
   public static void main(String[] args) {        
       int[] numbers={10,20,30,40,50};//定义一个数组        
       for (int i=0;i<5;i++){            
           System.out.println(numbers[i]);       }        System.out.println("===============================================================");        
//遍历数组元素      
       for (int x:numbers) {            
           System.out.println(x);       }   }}

 

posted on 2022-10-27 13:51  是芥末!日  阅读(10)  评论(0编辑  收藏  举报