### Question:
Interval { public static Interval[] createIntervals(Collection<Integer> indices) { int[] array = new int[indices.size()]; int i = 0; for (Integer index : indices) { array[i++] = index; } return createIntervals(array); } Interval(final int startIndex, final int endIndex); boolean intersects(Interval other); boolean intersects(Collection<Interval> col); static Interval[] createIntervals(Collection<Integer> indices); static Interval[] createIntervals(int[] indices); String toString(); final int startIndex; final int endIndex; }### Answer:
@Test public void create2() { int[] indices = new int[] { 5, 1, 3, 2 }; Interval[] intervals = Interval.createIntervals(indices); assertEquals("intervals.length", 2, intervals.length); }
@Test public void create3() { int[] indices = new int[] { 40, 20, 10, 41, 42, 43, 44, 15, 14, 13, 12, 11, 21, 22, 23, 25, 24 }; Interval[] intervals = Interval.createIntervals(indices); assertEquals("intervals.length", 3, intervals.length); }