The task preview hints that we could try and use collections here. So I gave it a go. I read in SO that the array[int] has to be converted to an object ArrayList in order to use Collections. So I kept failing and failing until I decided I was using to much time to try and solve this in a way we haven't learned how to implement yet. If anyone wants to shed some light on it that would be awesome.
package com.codegym.task.task07.task0728;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
/*
In decreasing order
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] array = new int[20];
// ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 20; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
sort(array);
for (int x : array) {
System.out.println(x);
}
}
public static void sort(int[] array) {
ArrayList<Integer> list = new ArrayList<Integer>(Arrays.asList(array));
Arrays.sort(list, Collections.reverseOrder());
}
}