#33 Converting a List of Strings into a List of Integers

Companies:
M.Video
Themes:
JavaStreams & LambdasPractice

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

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in