1.java.utils.Arrays.sort
public class sort {
public static void main(String[] args) {
int[] a = { 856, 7, 5, 6, 4, 2, 89, 125, 456, 963, 564, 4589, 3214, 6596 };
java.util.Arrays.sort(a);
print(a);
}
// 输出数组
public static void print(int[] temp) {
for (int x = 0; x < temp.length; x++) {
System.out.print(temp[x] + " ");
}
}
2.System.arraycopy(源数组名称,原数组开始点,目标数组名称,目标数组开始点,拷贝长度)。
public class 数组拷贝 {
public static void main(String[] args) {
int[] a = {1,3,5,7,9,0};
int[] b = {2,4,6,8,10};
System.arraycopy(b,0,a,1,5);
//System.arraycopy(原数组名称,原数组开始点,目标数组名称,目标数组开始点,拷贝长度)
for(int x=0;x<a.length;x++) {
System.out.print(a[x]);
}
}
System.arraycopy(原数组名称:从那个数组里面拷贝就写哪个名称,
原数组开始点:按数组元素的标号,从0开始数,从哪里开始拷贝就写几,
目标数组名称,:把数组拷贝到哪里去,就写哪个名称,
目标数组开始点:按数组元素的标号,从0开始数,从哪里开始写入就写几,4
拷贝长度:从拷贝原拷贝元素个数的长度)