Weird arithmetic result

exercise No. 272

Q:

We consider:

Code Ausgabe
IO.println('(' + 43 + ")");
IO.println("(" + 43 + ')');
83)
(43)

Explain this result. In particular: How do we get a value of 83?

A:

The + operator is being evaluated from left to right. The char Literal '(' represents 40. We thus have 40 + 43 == 83.