Java IntStream create from range

Description

Java IntStream create from range

import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    IntStream oneToFive  = IntStream.range(1, 6);
    oneToFive.forEach(System.out::print);
    //w  w w  .j  a va 2  s .  c om
    System.out.println();
    
    oneToFive  = IntStream.rangeClosed(1, 5);
    oneToFive.forEach(System.out::print);
    
    
  }
}



PreviousNext

Related