Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Optional<Integer> a = Optional.of(1);
- Optional<Integer> b = Optional.of(1);
- Optional<Integer> c = Optional.of(1);
- ...
- if (a.isPresent() && b.isPresent() && c.isPresent()) {
- return a.get() + b.get() + c.get();
- }
- ...
- Stream.of(a, b, c)
- .filter(Optional::isPresent)
- .map(Optional::get)
- .mapToInt(Integer::intValue)
- .sum();
- Optional<Integer> a = Optional.of(1);
- Optional<Integer> b = Optional.of(1);
- Optional<Integer> c = Optional.of(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement