Java Stream generate number sequence

Description

Java Stream generate number sequence


import java.util.stream.Stream;

public class Main {
   public static void main(String[] args) {
      Stream<Integer> stream = orderedNumberStream(10, 5, 10);

      stream.forEach(System.out::println);

   }/*from   w w w  . j av  a2s .c  om*/

   public static Stream<Integer> orderedNumberStream(int initialNum, int stepSize, int size) {
      return (Stream.iterate(initialNum, n -> n + stepSize).limit(size));
   }
}



PreviousNext

Related