首页 > 编程语言 > 详细

Java中遍历array

时间:2020-05-20 19:24:26      阅读:38      评论:0      收藏:0      [点我收藏+]

 

public class Test
{
    public static void main (String[] args)
    {
        String[] a = {"roll out", "rule out", "normalcy", "palaver", "satirical", "rut"};

        //下面提供两种遍历array的方法:
        //第一种方法:
         for (int i = 0; i < a.length; i++)
        {
            System.out.println(a[i]);
        }
        System.out.println(); //遍历后,换行

        //第二种方法:
        for (String item : a)
        {
            System.out.println(item);
        }
    }
}

 

Java中遍历array

原文:https://www.cnblogs.com/profesor/p/12924934.html

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