Precedence of evaluation for +
is from left to right and this is how it works:
System.out.println("3" + 3 + 3);
When you try this, since the first parameter is a String
, everything rest will be a String concatenation
System.out.println(3 + "3" + 3);
Same goes for this one, because you cannot add first int 3
to String 3
and then last 3
will be concatenated to second 3
System.out.println(3 + 3 + "3");
First left to right expression is evaluated (giving 3+3 = 6) and then string 3
is appended to result of that evaluation giving 63
as output