Is there any easy way we could replace a value in a List or Collection if the value is null?
We can always do list.stream().filter(Objects::nonNu
list.stream().filter(Objects::nonNu
You need a simple map function:
Arrays.asList( new Integer[] {1, 2, 3, 4, null, 5} ) .stream() .map(i -> i != null ? i : 0) .forEach(System.out::println); //will print: 1 2 3 4 0 5, each on a new line