太原理工大学java编程题有两个数组:数组a为1,7,9,11,13,15,17,19,数组b为2,4,6,8,
时间: 2023-10-22 17:09:13 浏览: 128
java的数组
好的,我明白了。针对您的问题,我可以给出以下Java代码实现将两个数组合并并按升序排列的结果:
```java
import java.util.Arrays;
public class MergeArrays {
public static void main(String[] args) {
int[] a = {1, 7, 9, 11, 13, 15, 17, 19};
int[] b = {2, 4, 6, 8};
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));
}
}
```
输出结果为:[1, 2, 4, 6, 7, 8, 9, 11, 13, 15, 17, 19]
阅读全文