Removing elements

Report a typo

Implement two methods.

The first method should create a set from a string of numbers separated by a space.

The second method should remove all numbers greater than 10 from the given set.

Sample Input 1:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Sample Output 1:

1 2 3 4 5 6 7 8 9 10
Write a program in Java 17
import java.util.*;

class SetUtils {

public static Set<Integer> getSetFromString(String str) {
// write your code here
}

public static void removeAllNumbersGreaterThan10(Set<Integer> set) {
// write your code here
}

}

/* Do not change code below */
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String numbers = scanner.nextLine();
Set<Integer> set = SetUtils.getSetFromString(numbers);
SetUtils.removeAllNumbersGreaterThan10(set);
set.forEach(e -> System.out.print(e + " "));
}
}
___

Create a free account to access the full topic