差别就是rangeClosed包含最后的结束节点,range不包含。
@Test public void test(){ IntStream.range(0,10).forEach( i -> System.out.println(i)); } @Test public void test1(){ IntStream.rangeClosed(0,10).forEach( i -> System.out.println(i)); }
range:
rangeClosed: