nums.length&nums[i]

时间:2014-08-28 21:07:06   收藏:0   阅读:479

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

原文:http://www.cnblogs.com/ammay/p/3942369.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!