×

Loading...

Are the following 4 pieces of code equivalent to each other?

1) for(int i=0; i<10; i++) {
System.out.println("i =" +i);
}
2) for(int i=0; i<10; ++i) {
System.out.println("i =" +i);
}
3) for(int i=0; i<10; ) {
System.out.println("i =" +i);
i++;
}
4) for(int i=0; i<10; ) {
System.out.println("i =" +i);
++i;
}

The question is: Are the above 4 pieces of code equivalent to each other? Can anybody tell me why? Thank you so much.
Sign in and Reply Report