My command parser compares if (cmd == "START"). It works in a unit test where cmd is assigned from a literal, but fails when cmd comes from reader.readLine(), even though printing both shows identical text. I see the same thing with numbers: two Integer variables both holding 100 compare equal with ==, but two holding 1000 do not.
What is == actually comparing, why does it sometimes appear to work, and what is the correct comparison in each case?




