数组复制
来源:互联网 发布:手机端js图片上传裁剪 编辑:程序博客网 时间:2024/05/08 14:16
数组复组,代码如下
class ArrayCopy
{
public static void main(String[] args)
{
int i1[]={1,2,3,4,5,6,7,8,9};
int i2[]={11,22,33,44,55,66,77,88,99};
System.arraycopy(i1,3,i2,1,3);//源数组,元数组开始点,目标数组,目标数组开始点,复制长度
print(i2);
}
public static void print(int yan[]){
for(int i=0;i<yan.length;i++){
System.out.print(yan[i]+" ");
}
}
}
class ShuZuFuZhi
{
public static void main(String[] args)
{
int i1[]={1,2,3,4,5,6,7,8,9};
int i2[]={11,22,33,44,55,66,77,88,99};
copy(i1,3,i2,1,3);
print(i2);
}
public static void copy(int s[],int s1,int o[],int s2,int len){
for(int i=0;i<len;i++){
o[s2+i]=s[s1+i];//原因?
}
}
public static void print(int yan[]){
for(int i=0;i<yan.length;i++){
System.out.print(yan[i]+" ");
}
}
}
输出结果11 4 5 6 55 66 77 88 99
- 复制数组(
- 数组复制
- 数组复制
- 复制数组
- 复制数组
- 复制数组
- 数组复制
- 复制数组
- 数组复制
- 数组复制
- 数组复制
- 数组复制
- 数组复制
- 复制数组
- 数组复制
- 数组复制
- 数组复制
- 复制数组
- Om Nom and Dark Park
- index
- LLDB 调试器中的解析
- c++的函数
- Zend Framework1-Zend_Filter_Input
- 数组复制
- red and black
- Dialog背景色透明效果轻松实现
- ADS射频电路学习笔记
- Catalan数的理解
- 剑指offer-跳台阶
- 六款值得推荐的android(安卓)开源框架简介
- 研究复杂网络1年多,总结下
- Linux 内核中的 Device Mapper 机制