/** * Adds an element to the stream being built. * * @implSpec * The default implementation behaves as if: * <pre>{@code * accept(t) * return this; * }</pre> * * @param t the element to add * @return {@code this} builder * @throws IllegalStateException if the builder has already transitioned * to the built state */ default Builder add(long t) { accept(t); return this; }
default Builder add(long t) { accept(t); return this; }
LongStream.Builder b = LongStream.builder(); for (int i = 1; i < dates.size(); i++) { b.accept(dates.get(i).getTime() - dates.get(i - 1).getTime()); } double mean = b.build().average().getAsDouble();