LongStream () { return IntStream.range(0, myRanges.length / 2) .mapToObj(idx -> LongStream.rangeClosed(myRanges[idx * 2], myRanges[idx * 2 + 1])) .reduce(LongStream::concat).orElseGet(LongStream::empty); }