int[] arr={71,54,58,29,31,78,2,77,87};//选择排序前,先循环打印数组元素System.out.print("排序前:");for (int i=0;i arr[j]) { int rec = arr[i]; arr[i] = arr[j]; arr[j] = rec; } }}System.out.print("排序后");for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] + " ");}