冒泡排序
@Test
public void test01() {
//1、定义一个数组模型
int[] arr = new int[]{2, 1, 6, 9, 4, 3};
//临时变量
int temp = 0;
//2、开始冒泡
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr.length - 1 - i; j++) {
if (arr[j] > arr[j + 1]) {
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
for (int i : arr) {
System.out.print(i+" ");
}
}