> For the complete documentation index, see [llms.txt](https://jihoony.gitbook.io/developers-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jihoony.gitbook.io/developers-notes/developer/readme/etcs/return-null-in-stream.md).

# Return null in stream

{% code overflow="wrap" %}

```java
list.stream()
    .map(i->someFunction(i))
    .filter(out -> out != null)
    .collect(Collectors.toList());
```

{% endcode %}

or

```java
list.stream()
    .map(i -> someFunction(i))
    .filter(Objects::nonNull)
    .collect(Collectors.toList());
```

or

```java
list.stream()
    .map(i -> someFunction(i))
    .filter(out -> true)
    .collect(Collectors.toList());
```
