public static void main(String[] args) {
int[] a = {4, 1, 5, 6, 7, 3, 230};
int temp = 0;
// 判断走多少次
for (int i = 0; i < a.length-1; i++) {
boolean flag = false;
for (int j = 0; j < a.length - 1 - i; j++) {
if (a[j + 1] < a[j]) {
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
flag = true;
}
}
if (flag == false) {
break;
}
}
System.out.println(Arrays.toString(a)); [1, 3, 4, 5, 6, 7, 230]
}