This content has been marked as final. Show 4 replies
Where can I find the "why" in java's documentation???
System.out.println(2+2 + "=four"); // same as System.out.println((2 + 2) + "=four");
System.out.println("forty-four=" + 4+4); // same as System.out.println(("fourty-four=" + 4) + 4);
It maybe somewhere in the JLS, but I would simply point you to this:
"When operators of equal precedence appear in the same expression, a rule must govern which is evaluated first. All binary operators except for the assignment operators are evaluated from left to right".
Your operators are all + operators, therefore they have the same precedence and therefore they are evaluated from left to right.
OMG! what a quick response!
Thanks a lot for your help!
You were very helpful!