java数组的for遍历

class ArrayDome 
{
    public static void main(String[] args) 
    {
        int[] arr = {12,51,12,11}; 

        //顺序遍历
        for(int x = 0; x < arr.length; x++)
        {
            System.out.println(arr[x]);
        }


        //反向遍历
        for(int x = arr.length-1; x >= 0; x--)
        {
            System.out.println(arr[x]);
        }


    }
}

猜你喜欢

转载自www.cnblogs.com/150643com/p/10357217.html
今日推荐