@Test public void test1() { //冒泡排序 int[] a = {3, 2, 1, 4, 5}; int i; for (i = 1; i <= a.length; i++) { for (int j = 0; j < a.length - 1 - i; j++) { if (a[j] > a[j + 1]) { int temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; } } } for (int x : a) { System.out.println(x); } }