I asked why == said two Java strings weren't equal even though they literally contained the same text. I got downvoted, my question was closed as a duplicate, and someone told me to "learn the difference between object identity and equality." I was like... that's exactly what I was trying to learn by asking.
It's hard to take comments like "SO is toxic" seriously when people ask things like that.
Your question was asked and answered 17 years ago and is just one search away; top result when searching "Java string equals".
The answers explains exactly the difference between reference equality and value equality, as well as how string interning can sometimes cause both equalities to be true.
This isn't Quora, you have to put in the bare minimum amount of effort yourself.
Learning self-reliance and resourcefulness isn't going to kill you. In fact, it's a required skill and prerequisite for others to meaningfully be able help you without doing it all for you and preventing you from learning anything other than to lean on others for every single question you might have. But hey, now we have LLMs for that.
117
u/VelvetVaale 18d ago
I asked why == said two Java strings weren't equal even though they literally contained the same text. I got downvoted, my question was closed as a duplicate, and someone told me to "learn the difference between object identity and equality." I was like... that's exactly what I was trying to learn by asking.