When should I use IntStream.range in Java?

前端 未结 7 1983
盖世英雄少女心
盖世英雄少女心 2020-12-29 01:34

I would like to know when I can use IntStream.range effectively. I have three reasons why I am not sure how useful IntStream.range is.

(Ple

7条回答
  •  感情败类
    2020-12-29 02:13

    IntStream.range returns a range of integers as a stream so you can do stream processing over it.

    like taking square of each element

    IntStream.range(1, 10).map(i -> i * i);  
    

提交回复
热议问题