天天看點

合并數組并排序

将合并數組合并,并按升序排列

int s[] ={,,,,,,,,,};
        int b[] ={,,,,,};
         int [] c= new int[s.length+b.length];
           System.arraycopy(s, , c, , s.length);  
           System.arraycopy(b, , c, s.length, b.length);
           Arrays.sort(c);
           for (int j = ; 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