Java little problem for loop
问题描述:
Java little problem for loop
what is a sentinel?write a for loop that prints all even numbers from 1 to 100.
答
public static void main(String[] args) {
for (int i = 2; i <=100; i += 2) {
System.out.println(i);
}
}