I came across this question, and I can vaguely tell it seems to be handling the number part as: A + B * C --> A * B + B * C
similarly, there are 3 more examples
1)
jshell> System.out.println("Sum is: " + 3 + 10*0.008);
Sum is: 30.08
jshell> System.out.println("Sum is: " + 33 + 10*0.008);
Sum is: 330.08
jshell> System.out.println("Sum is: " + 33 + 1000*0.8);
Sum is: 33800.0
According to String Concatenation, shouldn't it be:
- is "Sum is: 3.8"
- is "Sum is: 33.08"
- is "Sum is: 33800"
but it's not.
I remember we can even easily turn numbers into String by simply doing "" + number
; and if it was "" + number + number
--> would be ""numbernumber, not ""2number
How are these results produced exactly?