Converting a Stream of Optional to a Stream of Values

suggest change

You may need to convert a Stream emitting Optional to a Stream of values, emitting only values from existing Optional. (ie: without null value and not dealing with Optional.empty()).

Optional<String> op1 = Optional.empty();
Optional<String> op2 = Optional.of("Hello World");

List<String> result = Stream.of(op1, op2)

System.out.println(result); //[Hello World]

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents