数组排序与打印
public class ArrayDemo06 {
public static void main(String[] args) {
int[] a={111,55,66,88,9999,548455};
//打印数组元素
System.out.println(Arrays.toString(a));
pringArray(a);
//数组进行排序:升序
Arrays.sort(a);
System.out.println(Arrays.toString(a));
}
//模仿Arrays.toString(a)方法
public static void pringArray(int[] a){
for (int i = 0; i <a.length ; i++) {
if (i==0){
System.out.print("[");
}
if(i==a.length-1){
System.out.println(a[i]+"]");
}else{
System.out.print(a[i]+", ");
}
}
}
}