import java.util.*;
class Test{
public static void main(String[] args){
int[] a={1,7,11,13,15,17,19};
int[] b={2,4,6,8,10};
int[] c=new int[a.length+b.length];
System.arraycopy(a,0,c,0,a.length);
System.arraycopy(b,0,c,a.length,b.length);
Arrays.sort(c);
System.out.println(Arrays.toString(c));
}
}
public class Demo09 {
public static void main(String[] args) {
int a[] = new int[]{1, 7, 9, 11, 13,15, 17,19};
int b[] = new int[]{2, 4, 6, 8,10};
int c[]=new int [13];//计算好数组c所需大小
System.arraycopy(a,0,c,0,8);//使用arraycopy方法
System.arraycopy(b,0,c,8,5);
for(int i=0;i
}
}
}
c: 1,2,4,6,7,8,10,11,13,15,17,19
package asd;
import java.util.Arrays;
public class gg {
public static void main(String[] args) {
String a="1,7,9,11,13,15,17,19,";
String b="2,4,6,8,10";
String s=a+b;
String[] c=s.split(",");
int t[] = new int [13];
for(int i=0;i<13;i++)
t[i]=Integer.parseInt(c[i]);
Arrays.sort(t);
System.out.printf(Arrays.toString(t));
}
}
附结果:[1, 2, 4, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19]