Sort Array of Numbers in Descending Order using Java

Arrays.sort method

package app;

import java.util.Arrays;
import java.util.Collections;

public class Main
{
    public static void main(String[] args)
    {
        Integer[] numbers = {10, 3, 17, 50, 15};
        Arrays.sort(numbers, Collections.reverseOrder());

        System.out.println(Arrays.toString(numbers));
    }
}

Leave a Comment

Cancel reply

Your email address will not be published.