首页 > 其他 > 详细

nums.length&nums[i]

时间:2014-08-28 21:07:06      阅读:479      评论:0      收藏:0      [点我收藏+]

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]

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

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