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.
Taking elements
Sorting and skipping numbers
Report a typo
Sample Input 1:
21 0 33 1 8 15 19 8 4Sample Output 1:
15 19 21 33Write 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);
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.