首页 > 代码库 > javase-排序

javase-排序

 1 public class sort { 2     public static void main(String[] args) { 3         String[] arr = {"aa","bb","cc","dd"}; 4         System.out.println(Arrays.toString(arr)); 5 //        sort(arr); 6 //        System.out.println(Arrays.toString(arr)); 7         Arrays.sort(arr); 8         for (String string : arr) { 9             System.out.print(string);10         }11     }12 13     private static void sort(String[] arr) {14 15         for (int i = 0; i < arr.length-1; i++) {16             for (int j = i+1; j < arr.length; j++) {17                 String temp = arr[i];18                 arr[i] = arr[j];19                 arr[j] = temp;    20             }21         }22     }23 }

 

javase-排序