1Integer[] cubes = new Integer[] { 8, 27, 64, 125, 256 };
2Arrays.sort(cubes, Collections.reverseOrder());
3
4Read more: https://www.java67.com/2016/07/how-to-sort-array-in-descending-order-in-java.html#ixzz6MX60xZLb
1// A sample Java program to sort a subarray
2// in descending order using Arrays.sort().
3import java.util.Arrays;
4import java.util.Collections;
5
6public class SortExample
7{
8 public static void main(String[] args)
9 {
10 // Note that we have Integer here instead of
11 // int[] as Collections.reverseOrder doesn't
12 // work for primitive types.
13 Integer[] arr = {13, 7, 6, 45, 21, 9, 2, 100};
14
15 // Sorts arr[] in descending order
16 Arrays.sort(arr, Collections.reverseOrder());
17
18 System.out.printf("Modified arr[] : %s",
19 Arrays.toString(arr));
20 }
21}