import java.util.Arrays;
public class mergeTwoArrays {
public static void main(String[] args){
int[] array=new int[]{11,3,15,71,9};
int[] data=new int[]{21,4,62,8,10,12};
Arrays.sort(array);
Arrays.sort(data);
int[] rep=new int[array.length+data.length];
int m=0,i=0,j=0;
while (i<array.length&j<data.length){
if(array[i]<data[j]){
rep[m++]=array[i++];
}else {
rep[m++]=data[j++];
}
}
while (i<array.length){
rep[m++]=array[i++];
}
while (j<data.length){
rep[m++]=data[j++];
}
for(int d:rep){
System.out.print(d+" ");
}
}
}
网友评论