Iterable Range Assignment

From CSE425S Wiki
Revision as of 05:50, 25 November 2022 by Dennis.cosgrove (talk | contribs)
Jump to navigation Jump to search

Code To Investigate

Iterable

interface java.lang.Iterable<T>
Iterator<T> iterator()

Iterator

interface java.util.Iterator<T>
boolean hasNext()
T next()

Code To Implement

minToMaxExclusive

class: Ranges.java Java.png
methods: minToMaxExclusive
package: range.warmup
source folder: src/main/java
public static Iterable<Integer> minToMaxExclusive(int min, int maxExclusive)

Example

class: RangesExample.java Presentation icon-72a7cf.svg
package: range.example
source folder: src/main/java

The code:

for(int i : Ranges.minToMaxExclusive(4, 12)) {
	System.out.println(i);
}

produces the output:

4
5
6
7
8
9
10
11

Test

class: RangesTestSuite.java Junit.png
package: range.warmup
source folder: src/test/java