java冒泡排序
int [] numbers = new int[]{1,6,2,8,1,5,9}; for (int i = 0; i < numbers.length - 1; i++) { System.out.println(" i = " + i + " " + numbers[i]); for (int j = 0; j < numbers.length - i - 1; j++) { System.out.println(j); if (numbers[j] > numbers[j + 1]) { int temp = numbers[j]; numbers[j] = numbers[j + 1]; numbers[j + 1] = temp; } } } System.out.print("result = " ); for (int number : numbers) { System.out.print(" " + number); }