//冒泡排序 class BubbleSort{ public void sort(int[] a){ for (int i = 0; i < a.length-1; i++) { boolean flag = false; for (int j = a.length-1; j > i ; j--) { if (a[j-1] > a[j]){ int temp = a[j]; a[j] = a[j-1]; a[j-1] = temp; flag = true; } } if (!flag){ return; } } } }标签:sort,temp,int,flag,冒泡排序,length From: https://www.cnblogs.com/jixian/p/17154933.html