import java.util.Arrays;
public class CopyDemo {
public static void main(String[] args) {
int[] arr = {10,20,30,40,50,60,70,80};
System.out.println("数组为:"+ Arrays.toString(arr));
// 复制到新的数组
int[] newarry = Arrays.copyOf(arr,8);
System.out.println("新的数组为"+Arrays.toString(newarry));
// 复制到长度为10的新数组中
int[] arry2 = Arrays.copyOf(arr,10);
System.out.println("长度为10的数组:"+Arrays.toString(arry2));
// 变为长度为6个的数组
int[] arry3 = Arrays.copyOf(arr,6);
System.out.println("长度为6的数组:"+Arrays.toString(arry3));
}
}
import java.util.Arrays;
public class SortDemo {
public static void main(String[] args) {
int[] arr = {10,40,10,130,1,33,1123,4};
Arrays.sort(arr);
System.out.println("排序后的数组"+Arrays.toString(arr));
}
}