Default rules are generally ascending order
again to create an array of strings
sorted in ascending order output
Custom Type Sort
Create a Person class, getter and setter structure and parameters have no argument constructor
method overrides the toString
pass an object into the compiler error. Sort of Person class, there are no rules.
Integer and String are implements the interface the Comparable
the CompareTo method to rewrite the interface, it is a sort of method. Only this way can rewrite sorted according to the rules.
String class is to rewrite the CompareTo method
Person implement the Comparable interface
We want to sort Person, renowned for generic write the Person class. Comparable <Person>
override method CompareTo
own rules define the comparison
result output is arranged in ascending order of age.
Age flashback arrangement
collation.
On the other hand is descending