public class Bubbling { public static void mp(int num[]){ int swap = 0 ; //排序前 System.out.println("==== 排序前 ===="); for (int i = 0; i < num.length ; i++) { System.out.println(num[i]); } //排序后 for (int i = 0; i < num.length; i++) { for (int j = 0; j < num.length ; j++) { if(num[j] > num[i]){ swap = num[i]; num[i] = num[j]; num[j] = swap; } } } System.out.println("==== 排序后 ===="); for (int i = 0; i < num.length ; i++) { System.out.println(num[i]); } } public static void main(String[] args) { int[] nums = {22,30,59,89,64,3,100}; mp(nums); } }