Java tutorial
import java.util.OptionalLong; import java.util.stream.LongStream; public class Main { public static void main(String[] args) { LongStream b = LongStream.of(1L, 2L, 3L, 4L); OptionalLong v = b.reduce(Long::sum); if (v.isPresent()) { System.out.println(v.getAsLong()); } else { System.out.println("no value"); } } }