Java Arrays排序对象


Java Arrays排序对象

package com.codingdict;



import java.util.Arrays;



public class ArrayDemo {

   public static void main(String[] args) {



      // initializing unsorted Object array

      Object ob[] = {27, 11, 44};



      // let us print all the elements available in list

      for (Object number : ob) {

         System.out.println("Number = " + number);

      }



      // sorting array

      Arrays.sort(ob);



      // let us print all the elements available in list

      System.out.println("The sorted Object array is:");

      for (Object number : ob) {

         System.out.println("Number = " + number);

      }

   }

}