day04 java陣列 Arrays類
阿新 • • 發佈:2021-01-06
java陣列
Arrays類
public static void main(String[] args) {
int []a ={1,2,3,9000,1234,5346,6,7};
System.out.println(a);//[[email protected]
//列印陣列元素
System.out.println(Arrays.toString(a));//[1, 2, 3, 9000, 1234, 5346, 6, 7]
//排序
Arrays.sort(a);
System.out.println (Arrays.toString(a));//[1, 2, 3, 6, 7, 1234, 5346, 9000]
Arrays.fill(a,0);
System.out.println(Arrays.toString(a));//[0, 0, 0, 0, 0, 0, 0, 0]
//JDK幫助文件
}