Sorting and skipping numbers

Report a typo

In this exercise, you need to implement the processNumbers method that takes a collection of numbers and should sort it and skip all numbers that are less than 10. The method must return a sorted list as the result.

Sample Input 1:

21 0 33 1 8 15 19 8 4

Sample Output 1:

15 19 21 33
Write a program in Java 17
import java.util.*;
import java.util.stream.Collectors;

class ProcessNumbers {

public static List<Integer> processNumbers(Collection<Integer> numbers) {
// write your code here
}

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

Collection<Integer> numbers = Arrays.stream(scanner.nextLine().split("\\s+"))
.map(Integer::parseInt)
.collect(Collectors.toCollection(HashSet::new));

String result = processNumbers(numbers).stream()
.map(String::valueOf)
.collect(Collectors.joining(" "));

System.out.println(result);
}
}
___

Create a free account to access the full topic