Handy Iterable for a range of Integers
Not with this implementation of Iterable. You can use it like this:
for (int i : new Range(100)) System.out.printf("I have said this %d times. Read dzone.com!%n", i); class Range implements Iterable<Integer> { private final Integer stop; public Range(int stop) { this.stop = stop; } public Iterator<Integer> iterator() { return new Iterator<Integer>() { private Integer counter = 0; public boolean hasNext() { return (counter != stop); } public Integer next() { if (counter == stop) throw new NoSuchElementException(); return ++counter; } public void remove() { }}; } }