public class MaoPaoDemo { public static void main(String[] args) { int [] num = {2,3,10,9,7}; int temp = 0; /* 冒泡排序 */ for(int i = 0; i < num.length; i++){ for(int j = 0; j < num.length - 1; j++){ if(num[j]>num[j+1]){ temp = num[j]; num[j] = num[j+1]; num[j+1] = temp; } } } for (int n = 0;n < num.length; n++ ){ System.out.println(num[n]); } } }