Sort String array in reverse order in Java
Description
The following code shows how to sort String array in reverse order.
Example
// w ww. j a v a 2s . c om
import java.util.Arrays;
import java.util.Collections;
public class Main {
public static void main(String args[]) {
String[] myArray = new String[] { "A", "a", "B","java2s.com" };
Arrays.sort (myArray, Collections.reverseOrder());
System.out.println(Arrays.toString(myArray));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »