(String[] args)
| 6 | |
| 7 | public class ForInInt { |
| 8 | public static void main(String[] args) { |
| 9 | for(int i : range(10)) // 0..9 |
| 10 | System.out.print(i + " "); |
| 11 | System.out.println(); |
| 12 | for(int i : range(5, 10)) // 5..9 |
| 13 | System.out.print(i + " "); |
| 14 | System.out.println(); |
| 15 | for(int i : range(5, 20, 3)) // 5..20 step 3 |
| 16 | System.out.print(i + " "); |
| 17 | System.out.println(); |
| 18 | for(int i : range(20, 5, -3)) // Count down |
| 19 | System.out.print(i + " "); |
| 20 | System.out.println(); |
| 21 | } |
| 22 | } |
| 23 | /* Output: |
| 24 | 0 1 2 3 4 5 6 7 8 9 |