首页 > 代码库 > nums.length&nums[i]

nums.length&nums[i]

private void ex01()
{
int[] nums = { 8, 10, 3, 4, 12, 200 };


for (int i = nums.length - 1; i >= 1; i--)
{
System.out.println(nums.length);
if (i == 1)
{
System.out.println(nums[i]);
}
else
{
nums[i - 1] = nums[i];
System.out.format("%d,", nums[i]);
}
}

}

the output above are: 200, 200, 200, 200, 200

you should understand nums.length start counting at 1, nums[i] start counting at 0

nums.length&nums[i]