fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static Iterable<Integer> range(final int from, final int to) {
  11. return new Iterable<Integer>() {
  12. public Iterator<Integer> iterator() {
  13. return new Iterator<Integer>() {
  14. int current = from;
  15. public boolean hasNext() { return current < to; }
  16. public Integer next() {
  17. if (!hasNext()) { throw new NoSuchElementException(); }
  18. return current++;
  19. }
  20. public void remove() {}
  21. };
  22. }
  23. };
  24. }
  25. public static void main (String[] args) throws java.lang.Exception
  26. {
  27. for (Integer n : range(10, 20)) {
  28. System.out.println(n);
  29. }
  30. }
  31. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
10
11
12
13
14
15
16
17
18
19