Daniel Cox wrote: According to the JLS
Thanks Daniel for linking this document. I didn't really understand the run time blurb when I read it(and franky, I'm still not sure I do). But there's an example on that page and I'll paste in the explanation in case anyone else comes across this
thread looking for the answer...
I've edited the method and variable names to match my question:
The occurrence of str1 before ".equals" is evaluated first, before the argument expression str1 = str2. Therefore, a reference to the string "one" is remembered as the target reference before the local variable str1 is changed to refer to the string "two". As a result, the equals method is invoked for target object "one" with argument "two", so the result of the invocation is false.