17.3.6 Creating Streams of ints with IntStream Methods range and rangeClosed

If you need an ordered sequence of int values, you can create an IntStream containing such values with IntStream methods range (line 63 of Fig. 17.5) and rangeClosed (line 67). Both methods take two int arguments representing the range of values. Method range produces a sequence of values from its first argument up to, but not including its second argument. Method rangeClosed produces a sequence of values including both of its arguments. Lines 63 and 67 demonstrate these methods for producing sequences of int values from 1–9 and 1–10, respectively. For the complete list of IntStream methods, visit:

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.