在Java中可以使用 System类中arraycopy 进行数组的拷贝 操作。
//public static void arraycopy(Object src, 源数组
// int srcPos, 从哪个位置开始拷贝
// Object dest, 目标数组
// int destPos, 从哪个位置开始复制
// int length) 复制多少长度
package test;
import java.util.Arrays;
public class Systemdemo {
public static void main(String[] args) {
//数组的拷贝操作
//public static void arraycopy(Object src,
// int srcPos,
// Object dest,
// int destPos,
// int length)
int[] src = {1,2,34,5,6,6,7,0};
int[] desc = {3,4,4,5,55};
System.out.println(Arrays.toString(desc)); //打印数组
System.arraycopy(src,3,desc,0,3);
System.out.println(Arrays.toString(desc));
String [] strings = new String[]{"ABC","ccc","tht","嗷嗷","哈哈",",,"};
String[] stringsdesc = new String[]{"hi","love"," ss"};
System.out.println(Arrays.toString(strings));
System.arraycopy(strings, 2, stringsdesc, 0,3);
System.out.println(Arrays.toString(stringsdesc));
}
}