Hi all, I'm having some problems solving this.
The code I wrote doesnt work because Collections.reverseOrder() doesnt like integers.
If I use a String array with String values, it works only for positive numbers (obviously).
How can I solve this?
Here attached you can find the "Int" version.
Thank you!
package com.codegym.task.task04.task0420;
/*
Sorting three numbers
*/
import java.io.*;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
int [] arr = new int [3];
for (int i = 0; i < arr.length; i++){
arr[i] = scanner.nextInt();
}
Arrays.sort(arr, Collections.reverseOrder());
for (int i = 0; i < arr.length; i++){
System.out.print(arr[i] + " ");
}
}
}