冒泡排序
import java.util.*; public class Bubble{ public int[] getBubble(int[] array){ if(array == null || array.length == 0) return null; for(int i=0;i<array.length;i++){ for(int j=i+1;j<array.length;j++){ if(array[i]>array[j]){ int temp = array[i]; array[i] = array[j]; array[j] = temp; } } } return array; } public static void main(String[] args){ int[] array = {1,100,234,44,3,2,4,5}; Bubble b = new Bubble(); array = b.getBubble(array); System.out.println(Arrays.toString(array)); } }