一个在Java中关于arraycopy()方法~~~~~是什么意思,

来源:百度知道 编辑:UC知道 时间:2024/09/27 08:20:31
一个在Java中关于arraycopy()方法~~~~~是什么意思,是怎么用的,能不能拿出一个详细的例子来说明~~

public static void arraycopy(Object src,
int srcPos,
Object dest,
int destPos,
int length)

Parameters:
src - the source array.源数据
srcPos - starting position in the source array.起始下标
dest - the destination array.目标源
destPos - starting position in the destination data.起始下标
length - the number of array elements to be copied. 想拷贝的长度

利用java.util.Arrays的copyOf方法来进行数组的拷贝

String[] from = { "3", "4", "5", "2", "1" };
String[] to = Arrays.copyOf(from, from.length);