[Java] Primitive Stream

public class Code {
  public static void main(String[] args) {
    IntStreams.range(1,4)
          .forEach(System.out::println); // 1 2 3
    
    Arrays.stream(new int[] {1,2,3,4})
          .map(n -> n * n)
          .average()
          .ifPresent(System.out::println); // 7.5
    
    Stream.of(1.5,2.3, 3.7)
          .mapToInt(Double::intValue)
           .forEach(System.out::println); // 1 2 3
  }
}
原文地址:https://www.cnblogs.com/Answer1215/p/14209575.html