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

Method range

onjava/Range.java:10–22  ·  view source on GitHub ↗
(int start, int end, int step)

Source from the content-addressed store, hash-verified

8public class Range {
9 // Produce sequence [start..end) incrementing by step
10 public static
11 int[] range(int start, int end, int step) {
12 if (step == 0)
13 throw new
14 IllegalArgumentException("Step cannot be zero");
15 int sz = Math.max(0, step >= 0 ?
16 (end + step - 1 - start) / step
17 : (end + step + 1 - start) / step);
18 int[] result = new int[sz];
19 for(int i = 0; i < sz; i++)
20 result[i] = start + (i * step);
21 return result;
22 } // Produce a sequence [start..end)
23 public static int[] range(int start, int end) {
24 return range(start, end, 1);
25 }

Callers 15

mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
testMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80

Calls 1

maxMethod · 0.65

Tested by 1

mainMethod · 0.64