|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjparfor.Range
public class Range
Implement an iterable range that is computed lazily. The range will start at the start value (inclusive) and end at the end value (exclusive) doing increments of step size each time towards the end. A for loop as for (int i = 5; i < 22; i += 3) can now be replaced by for (int i : new Range(5, 22, 3))
Nested Class Summary | |
---|---|
class |
Range.RangeIterator
Iterator object for the range object. |
Constructor Summary | |
---|---|
Range(int end)
Create an iterable range object with the following properties (start = 0, step = 1). |
|
Range(int start,
int end)
Create an iterable range object with the following properties (step = 1). |
|
Range(int start,
int end,
int step)
Create an iterable range object with the following properties. |
Method Summary | |
---|---|
int |
getEnd()
Return the end of the range object. |
int |
getStart()
Return the start of the range object. |
int |
getStep()
Return the step of the rage object. |
java.util.Iterator<java.lang.Integer> |
iterator()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Range(int start, int end, int step)
start
- start value (inclusive).end
- end value (exclusive).step
- size of the increment between values (> 0).public Range(int start, int end)
start
- start value (inclusive).end
- end value (exclusive).public Range(int end)
end
- end value (exclusive).Method Detail |
---|
public int getStart()
public int getEnd()
public int getStep()
public java.util.Iterator<java.lang.Integer> iterator()
iterator
in interface java.lang.Iterable<java.lang.Integer>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |