(String[] args)
| 7 | |
| 8 | public class StreamOfOptionals { |
| 9 | public static void main(String[] args) { |
| 10 | Signal.stream() |
| 11 | .limit(10) |
| 12 | .forEach(System.out::println); |
| 13 | System.out.println(" ---"); |
| 14 | Signal.stream() |
| 15 | .limit(10) |
| 16 | .filter(Optional::isPresent) |
| 17 | .map(Optional::get) |
| 18 | .forEach(System.out::println); |
| 19 | } |
| 20 | } |
| 21 | /* Output: |
| 22 | Optional[Signal(dash)] |