The message is:
Main.java:14: error: ')' expected
System.out.println(1 ++ 2);
^
The 1 ++ 2
statement is parsed as 1
followed by ++
followed by 2
. This is interpreted as 1++
and 2
creating a syntax error (and not an unexpected type
error; in fact, you will get the same error if you used variables e.g. i ++ j
).
The 1 + + 2
statement on the other hand is parsed as 1
followed by +
followed by +2
which compiles as expected. The space between the two operators separates the two operators.