Weird Java Syntax

java, syntax

Solution

I added some parentheses:

int a = 5;
int b = 7;
int c = 10;
c = (b++) + (-(c--)) + (--a);
System.out.println(a + " " + b + " " + c);

b++ : b = b + 1 after b is used

c-- : c = c - 1 after c is used

--a : a = a - 1 before a is used

Problem

I was doing a practice Computer Science UIL test form when I came across this problem: What is output by the following? ``` int a = 5; int b = 7; int c = 10; c = b+++-c--+--a; System.out.println(a + " " + b + " " + c); ``` I put down the answer "No output due to syntax error" but I got it wrong. The real answer was 4 8 1! (I tested it out myself) Can someone please explain to me how line 4 works? Thanks

Original source