[Solved] Java: find the output of the code with double quotes and assignment operator [closed]


System.out.println(""+4+2); -> 42

Because first you are adding and empty string and a int value. Result will be a string. Then you are adding an another int to that string. So it will concatenate the just string representation of value to the previous string and output 42

System.out.println(4+2+""); -> 6

Here you are first adding 2 integers so it will results 6 as a int value. Then you are adding empty string to that int value. So the final result will be 6 as a string

solved Java: find the output of the code with double quotes and assignment operator [closed]