博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java_数组copy
阅读量:4659 次
发布时间:2019-06-09

本文共 575 字,大约阅读时间需要 1 分钟。

public static void main(String[] args) {

int [] scoreList = new int[5];
scoreList[0] = 68;
scoreList[1] = 78;
scoreList[2] = 88;
scoreList[3] = 98;
scoreList[4] = 58;
/*
*1: 创建新的数组。长度是原来的1.5倍。
*2:依次取出原来数组的元素。取出放到新数组里
*/
int [] newList = new int[7];
// for(int i:scoreList ) {
// newList[]= i;
// }
// for(int i =0;i<scoreList.length;i++) {
// newList[i] = scoreList[i];
// }
for(int i :newList) {
System.out.println(i);
}
System.arraycopy(scoreList, 0, newList, 0, 3);
for (int i : newList) {
System.out.println(i);
}
}
}

转载于:https://www.cnblogs.com/lipeitong/p/11053096.html

你可能感兴趣的文章
shell脚本颜色的设置
查看>>
2019春总结作业
查看>>
小程序数据绑定的拓展用法
查看>>
DRF 版本 认证
查看>>
MVC 4将jQuery升级到1.9出现各种问题。。。
查看>>
JedisPool资源池优化
查看>>
第2次作业+105032014140
查看>>
JS防抖与节流
查看>>
redhat enterprixe 5.0 DNS 服务配置与管理
查看>>
Django ORM不完全操作
查看>>
hdu2089
查看>>
windows下使用PHP实现定时执行脚本
查看>>
Linux下常用的压缩与解压命令
查看>>
第一周的博客作业
查看>>
linux的awk命令解读
查看>>
JavaScript内部原理实践——真的懂JavaScript吗?(转)
查看>>
android5.0之toolBar
查看>>
POJ--2689-C++
查看>>
better-scroll的使用方法,动态创建dom使用better-scroll
查看>>
PHP中的面向对象魔术方法大全
查看>>