Home > Back-end >  The Arrays class implements the sorting can someone something about its principle?
The Arrays class implements the sorting can someone something about its principle?

Time:05-15

System. The out. Println (" through the Comparator interface, polymorphism mechanism, an anonymous inner class to implement custom sorting: ");
8,9,4,10,5,6,1 Integer [] arr2={};//array wrapper class
The Arrays. Sort (arr2, new Comparator () {
@ Override//rewrite the compare of the interface methods
Public int the compare (Integer o1, o2) Integer {
The Integer In1=(Integer) o1;
The Integer In2=(Integer) o2;
Return In1 and In2.
}
});
System. The out. Println (Arrays. ToString (arr2));
  • Related