import java.util.Iterator;
import java.util.NoSuchElementException;
public class BasicIterator {
public static class Stepper implements Iterator<Integer>,
Iterable<Integer> {
private int start, step, end, curr;
public Stepper(int start, int step, int end) {
this.start = start;
this.step = step;
this.end = end;
this.curr = start;
}
public boolean hasNext() {
return curr < end;
}
public Integer next() {
int n = curr;
curr += step;
return n;
}
public void remove() {
throw new UnsupportedOperationException();
}
public Iterator<Integer> iterator() {
return this;
}
}
public static void main(String[] args) {
for(int i : new Stepper(0, 2, 10)) {
System.out.println(i);
}
}
}