public class TestFor {
public static void main(String[] args) {
int x, y;
for (x=1,y=0; x < 5; x++, y++) (x++);
{ y++; }
System.out.println("The value of x is =" + x);
System.out.println("The value of y is =" + y);
}
}
This will print x=5
y=3
x=1 |y=0
x=x++=2 |y=y++=1
x=x++=3 |
x=3 |y=1
x=x++=4 |y=y++=2 after terminated
x=x++=5 |{y++}will take incremented to 3.
x<5 for loop will terminate now.
1.one thing we have know {y++} different statement this will take notice after the loop terminated.
2.(x++);will take within the for loop method count,note the difference.
correct me If I'm wrong