this.count = count;
return new Iterator<Integer>() { private int i = 0; public boolean hasNext() { return i < count; } public Integer next() { i++; return i; } public void remove(){ throw new UnsupportedOperationException(); } };
int total = 0; for (int i : new Counter(3)) { total += i; } assert total == 6;