#33 Converting a List of Strings into a List of Integers
Implement a method using the Stream API that returns a List<Integer> based on data from an input List<String>:
public class Main {
public static void main (String[] args) {
List<String> example = List.of("1", "2", "3", "four", null);
List<Integer> result = converToIntegerList(example);
System.out.println(result); //Output: [1, 2, 3]
}
public static List<Integer> convertToIntegerList(List<String>strings) {
// write your code here
}
}
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor