packagearray;importjava.util.Arrays;publicclassDemo6{publicstaticvoidmain(String[] args){int[] a ={1,2,3,4,43434,45656,74525,1235656,64646546,66};System.out.println(a);//[I@1b6d3586//打印数组元素 Arrays.toStringSystem.out.println(Arrays.toString(a));
packagearray;importjava.util.Arrays;publicclassDemo6{publicstaticvoidmain(String[] args){int[] a ={1,2,3,4,43434,45656,74525,1235656,64646546,66};System.out.println(a);//[I@1b6d3586//打印数组元素 Arrays.toStringSystem.out.println(Arrays.toString(a));printArray(a);}publicstaticvoidprintArray(int[] a){for(int i =0; i <a.length ; i++){if(i==0){System.out.print("[");}if(i==a.length-1){System.out.print(a[i]+"]");}else{System.out.print(a[i]+" ,");}}}}
排序
packagearray;importjava.util.Arrays;publicclassDemo6{publicstaticvoidmain(String[] args){int[] a ={1,2,3,4,43434,45656,74525,1235656,64646546,66};System.out.println(a);//[I@1b6d3586Arrays.sort(a);//数组排序System.out.println(Arrays.toString(a));}}
数组填充
packagearray;importjava.util.Arrays;publicclassDemo6{publicstaticvoidmain(String[] args){int[] a ={1,2,3,4,43434,45656,74525,1235656,64646546,66};Arrays.fill(a,0);//数组填充System.out.println(Arrays.toString(a));}}