java for循环
public class Sample { public static void main(String[] args) { for (int i = 1; i <= 10; i++) { System.out.print(i + " "); } } } OUTPUT: 1 2 3 4 5 6 7 8 9 10
demo2
public class Sample { public static void main(String[] args) { for (int i = 1; i <= 10; i += 2) { System.out.print(i + " "); } } } OUTPUT: 1 3 5 7 9
demo3
public class Sample { public static void main(String[] args) { for (int i = 10; i >= 1; i--) { System.out.print(i + " "); } } } OUTPUT: 10 9 8 7 6 5 4 3 2 1