(b, 0, c, 0, b.length)什么意思?

来源:百度知道 编辑:UC知道 时间:2024/05/09 20:48:54
public static void main(String[] args) {
int[] a = { 1, 6, 4, 9, 8, 7 }, b = { 3, 4, 5, 10 };

// 将 a,b合并
int[] c = new int[a.length + b.length];
System.arraycopy(b, 0, c, 0, b.length);
System.arraycopy(a, 0, c, b.length, a.length);

// 排序
Arrays.sort(c);

// 打印校对
for(int i = 0;i<c.length;i++)
System.out.print(c[i] + " ");
}

public static void arraycopy(Object src,
int srcPos,
Object dest,
int destPos,
int length)src:源数组; srcPos:源数组要复制的起始位置;dest:目的数组; destPos:目的数组放置的起始位置; length:复制的长度。注意:src and dest都必须是同类型或者可以进行转换类型的数组