數組排序


public static void main(String[] args) {
	  Integer[] arr={9,8,7,6,11,4,23,2,1};
	  //降序 1
      Arrays.sort(arr,Collections.reverseOrder());
      for(int i:arr){
          System.out.println(i);
      }
      //降序2

      
      //升序
      Arrays.sort(arr);
      System.out.println("--------------------");
      for(int i:arr){
          System.out.println(i);
      }
  }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章