Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

sort method in java array

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

class ArraySort {
    public static void main(String[] args) {
        Integer[] arr = { 5, 2, 1, 8, 10 };
        Arrays.sort(arr, Collections.reverseOrder());
        
        for (int values : arr) {
            System.out.print(values + ", ");
            // 10, 8, 5, 2, 1,
        }
    }
}
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #sort #method #java #array
ADD COMMENT
Topic
Name
1+6 =