MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

streams/Ranges.java:8–23  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

6
7public class Ranges {
8 public static void main(String[] args) {
9 // The traditional way:
10 int result = 0;
11 for(int i = 10; i < 20; i++)
12 result += i;
13 System.out.println(result);
14
15 // for-in with a range:
16 result = 0;
17 for(int i : range(10, 20).toArray())
18 result += i;
19 System.out.println(result);
20
21 // Use streams:
22 System.out.println(range(10, 20).sum());
23 }
24}
25/* Output:
26145

Callers

nothing calls this directly

Calls 2

rangeMethod · 0.80
sumMethod · 0.80

Tested by

no test coverage detected