温故知新 数组

public class Array {
public static void main(String[] args) {
int[] arr=new int[10];
for(int i=0;i<arr.length;i++) {

//0--100间取值
arr[i]=(int) (Math.random()*100);
}

//数组转字符串

System.out.println(Arrays.toString(arr));

//排序(递增)
Arrays.sort(arr);
System.out.println(Arrays.toString(arr));

//数组数据拷贝

int[] max=Arrays.copyOf(arr, arr.length);
System.out.println(Arrays.toString(max));

//数据数据截取
int[] min=Arrays.copyOf(arr, 3);
System.out.println(Arrays.toString(min));


int[] midth=new int[arr.length*2];
System.arraycopy(arr, 0, midth, 0, arr.length);
System.out.println(Arrays.toString(midth)+",midth的数组长度:"+midth.length);
}

}

posted @ 2020-03-24 14:35  唯恐不及  阅读(95)  评论(0编辑  收藏  举报