Loading

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 }

 

posted @ 2016-09-17 15:14  书中人007  阅读(165)  评论(0编辑  收藏  举报
拈花微笑·恬淡诠释生命