将合并数组合并,并按升序排列
int s[] ={1,3,5,7,9,11,13,15,17,19};
int b[] ={2,4,5,6,7,10};
int [] c= new int[s.length+b.length];
System.arraycopy(s, 0, c, 0, s.length);
System.arraycopy(b, 0, c, s.length, b.length);
Arrays.sort(c);
for (int j = 0; j < c.length; j++) {
System.out.println(c[j]);
}
/* 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.
*/
运行结果:
1
2
3
4
5
5
6
7
7
9
10
11
13
15
17
19