Difference between revisions of "Iterable Range Assignment"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
− | = | + | =Java= |
− | + | [https://www.w3schools.com/java/java_methods_overloading.asp Method Overloading] | |
− | |||
− | |||
− | + | [https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html Nested Inner Classes] | |
− | [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html | + | |
− | :[https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#hasNext-- | + | [https://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html Anonymous Classes] |
− | :[https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#next-- | + | |
+ | [https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html Lambda Expressions] | ||
+ | |||
+ | interface [https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html java.lang.Iterable<T>] | ||
+ | :[https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html#iterator-- iterator()] | ||
+ | |||
+ | interface [https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html java.util.Iterator<T>] | ||
+ | :[https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#hasNext-- hasNext()] | ||
+ | :[https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#next-- next()] | ||
=Code To Implement= | =Code To Implement= |
Revision as of 02:32, 26 November 2022
Java
interface java.lang.Iterable<T>
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)
Client
class: | RangesClient.java | |
package: | range.client | |
source folder: | src/main/java |
The code:
for (int i : Ranges.minToMaxExclusive(4, 12)) { System.out.println(i); } System.out.println(); for (double d : Ranges.minToMaxExclusive(3, 7.1, 0.25)) { System.out.println(d); }
produces the output:
4 5 6 7 8 9 10 11 3.0 3.25 3.5 3.75 4.0 4.25 4.5 4.75 5.0 5.25 5.5 5.75 6.0 6.25 6.5 6.75 7.0
Test
class: | RangesTestSuite.java | |
package: | range.warmup | |
source folder: | src/test/java |