OnJava8-Examples/control/ForEachInt.java

24 lines
522 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// control/ForEachInt.java
2015-06-15 17:47:35 -07:00
// <20>2015 MindView LLC: see Copyright.txt
import static com.mindviewinc.util.Range.*;
import static com.mindviewinc.util.Print.*;
public class ForEachInt {
public static void main(String[] args) {
for(int i : range(10)) // 0..9
printnb(i + " ");
print();
for(int i : range(5, 10)) // 5..9
printnb(i + " ");
print();
for(int i : range(5, 20, 3)) // 5..20 step 3
printnb(i + " ");
print();
}
2015-09-07 11:44:36 -06:00
}
/* Output:
2015-06-15 17:47:35 -07:00
0 1 2 3 4 5 6 7 8 9
5 6 7 8 9
5 8 11 14 17
2015-09-07 11:44:36 -06:00
*/