Difference between revisions of "Iterable Range Assignment"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
=Code To Investigate= | =Code To Investigate= | ||
==Iterable== | ==Iterable== | ||
− | + | [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html interface java.lang.Iterable<T>] | |
− | + | :[https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html#iterator-- Iterator<T> iterator()] | |
==Iterator== | ==Iterator== | ||
− | + | [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html interface java.util.Iterator<T>] | |
− | + | :[https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#hasNext-- boolean hasNext()] | |
− | + | :[https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#next-- T next()] | |
=Code To Implement= | =Code To Implement= |
Revision as of 05:51, 25 November 2022
Contents
Code To Investigate
Iterable
interface java.lang.Iterable<T>
Iterator
interface java.util.Iterator<T>
Code To Implement
minToMaxExclusive
class: | Ranges.java | |
methods: | minToMaxExclusive | |
package: | range.warmup | |
source folder: | src/main/java |
public static Iterable<Integer> minToMaxExclusive(int min, int maxExclusive)
Example
class: | RangesExample.java | |
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 | |
package: | range.warmup | |
source folder: | src/test/java |