public class IntegerSequence extends BaseFieldGenerator<Integer>
Integer.| Constructor and Description |
|---|
IntegerSequence(int start,
int stop)
Build a sequence that will return values between
start and end (inclusive) with an increment of
1. |
IntegerSequence(int start,
int stop,
int increment)
Build a sequence that will return values between
start and end (inclusive) with an increment of
increment. |
| Modifier and Type | Method and Description |
|---|---|
Integer |
current()
Returns the current sequence value.
|
boolean |
hasNext()
Returns
true if the generator has more value to generate (In other words, returns true if
next would return a value rather than throwing an exception.) |
Integer |
next()
Returns the next generated value.
|
void |
reset()
Resets the
IntegerSequence. |
String |
toString() |
removepublic IntegerSequence(int start,
int stop,
int increment)
start and end (inclusive) with an increment of
increment. For instance, in:
s1 = new IntegerSequence(1, 10, 2);
s2 = new IntegerSequence(1, 10, 1);
s1 will generate the following numbers: 1, 3, 5, 7, 9 and s2 will generate 1, 2, 3, 4, 5, 6, 7,
8, 9, 10.start - first value in sequence, inclusive.stop - last element in sequence, inclusive.increment - increment.IllegalArgumentException - if start is less than stop or if increment is less than or equal to 0.public IntegerSequence(int start,
int stop)
start and end (inclusive) with an increment of
1.start - first value in sequence, inclusive.stop - last element in sequence, inclusive.IntegerSequence(int, int, int)public void reset()
public boolean hasNext()
true if the generator has more value to generate (In other words, returns true if
next would return a value rather than throwing an exception.)true if the iteration has more value.public Integer next()
NoSuchElementException - if the iteration has no more value.public Integer current()
next if next was never called before since
creation of last reset().Copyright © 2014. All Rights Reserved.