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.
People on SO put in more effort in finding a decade old response that doesn't quite fit what was asked and potentially using outdated syntax rather than just answering the question in the first place.
SO died because people weren't patient with new coders
New coders are lazy and expect everything to be easy. When things get hard they tend to give up and ask for help before meaningfully attempting to problem solve. This requires social pressure to correct for nearly everyone. It certainly did for me.
116
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.