java冒泡排序

 1 public static void main(String[] args) 
 2     {
 3 
 4             int[] arr = {10,6,13,15,9,216};
 5         for(int i =0;i<arr.length-1;i++){
 6 
 7             for(int j=0;j<arr.length-1-i;j++){
 8 
 9                 if(arr[j]>arr[j+1]){
10                     int temp = arr[j];
11                     arr[j]=arr[j+1];
12                     arr[j+1] = temp;
13                       }
14              }        
15           }    
16 for(int j = 0 ; j<arr.length;j++){
17         
18             System.out.println(arr[j]);
19         }
20     }

据说很重要,放着别丢了

原文地址:https://www.cnblogs.com/xpqsd/p/6063010.html