Why does java compiler gives
'2' is a char, so '2' + '2' adds the int value of that character to itself (50+50) and then appends "a" to it, giving you 100a.
"a" + '2' + '2' performs String concatenation, since the first operand is a String. Therefore you get a22.
Note that the expressions are evaluated from left to right, so the types of the first two operands determine whether + will perform an int addition or a String concatenation.