We would like to know how to create IntStream with builder.
//from w w w.j ava2s . c om import java.util.stream.IntStream; public class Main { public static void main(String[] args) throws Exception { IntStream .builder() .add(1) .add(3) .add(5) .add(7) .add(11) .build() .average() .ifPresent(System.out::println); } }
The code above generates the following result.