见如下代码及运行结果:
输出结果:
[b]y = 0
x = 1
y = 1[/b]
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
int x = 0;
int y = 0;
for (int i = 0; i < 2; i++) {
if (x++ > 0) {
System.out.println("x = " + i);
}
if (++y > 0) {
System.out.println("y = " + i);
}
}
}
}
输出结果:
[b]y = 0
x = 1
y = 1[/b]