I am practicing the java post and pre increment operators where I have a confusion to understand the output of the below program. How it have generated the output as "8" ?
public class Test{
public static void main(String [] args){
int x=0;
x=++x + x++ + x++ + ++x;
System.out.println(x);
}
}
I have tried some more sample programs where I am able to track the outputs
public class Test{
public static void main(String [] args){
int x=0;
x=++x + ++x + ++x + x++;
// 1 + 2 + 3 + 3 =>9
System.out.println(x);
}
}