//冒泡排序 public static void main(String[] args) { int [] nums = {12,21,11,1,1314,341}; for(int i = 0; i<nums.length-1; i++) { for(int j = 0; j<nums.length-1-i; j++) { if(nums[j]>nums[j+1]) { int tem = 0; tem = nums[j]; nums[j] = nums[j+1]; nums[j+1] = tem; } } } for (int i : nums) { System.out.println(i); } }