Hi,
Sorry for the english. Sitting for exam so a bit panic. pls help...
I have a program like below:
public static void main(String [] args){
int x=3;
int y;
y=x++ % ++x;
System.out.println(y);
System.out.println(x);
}
}
When i ran y is 3 and x is 5. I read from book, it says that unary operators are evaluated from right to left..
So, if this is the case, ++x is evaluated first ( x=4) , then , x++, so, x=4, y=0 and not 3...pls clarify
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.