In a table precedence in C++, I've seen the prefix and postfix operators shown in separate places. In the seemingly rare times when someone actually lists a precedence table in
Java, they don't make that distinction. So I did a
test:
public class ATest
{
static int i=1;
static int j=2;
public static void main(
String args[])
{
int k=i+(j=i++); // Line in question
System.out.println("i="+i);
System.out.println("j="+j);
System.out.println("k="+k);
}
}
The line in question wouldn't compile when I left out the parenthesis, but with them it showed i=2 j=1 and k=2. Can I then assume it
1. Set j=1
2. Set k=i+j which is k=1+1 which is 2
3. Set i=i+1 which is i=2
Does this mean that it does the postfix operations after all the other assignments are done?
Thanks,
Ben