+ 1
Why ++x and x++ are showing same result in this code?
public class Program { public static void main(String[] args) { for(int x = 1; x <=5; x++) { System.out.println(x); } } }
1 Respuesta
+ 7
You'll get the answer if you try it this: System.out.println(++x) and System.out.println(x++) 😉
Okay, little explanation: You increased the values independent from the print-command. So it is the same either you increase it post or pre loop header.