Java Stream create from iterate() and limit() method

Description

Java Stream create from iterate() and limit() method

import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {
    Stream<Long> s = Stream.iterate(1L, n  ->  n  + 1)
        .limit(10);/*ww  w .j a  v a 2 s. co m*/

    s.forEach(System.out::println);
    
    
  }
}



PreviousNext

Related