首页 > 其他 > 详细

复制数组的方法

时间:2014-04-21 01:03:36      阅读:536      评论:0      收藏:0      [点我收藏+]

1.使用FOR循环
int[] src={1,3,5,6,7,8};
int[] dest = new int[6];
for(int i=0;i<6;i++) dest[i] = src[i];
2.
使用clone
int[] src={1,3,5,6,7,8};
int[] dest;
dest=(int[]) src.clone();//
使用clone创建
副本,注意clone要使用强制转换
3.
使用System.arraycopy
int[] src={1,3,5,6,7,8};
int[] dest = new int[6];
System.arraycopy(src, 0, dest, 0, 6);
< !--[if !supportLineBreakNewLine]-->
< !--[endif]-->

复制数组的方法,布布扣,bubuko.com

复制数组的方法

原文:http://www.cnblogs.com/-try/p/3675990.html

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