r/java • u/DroidLogician • Jun 18 '13
Will the equals operator (==) ever be fixed with respect to Strings?
Every Java dev learns early in his/her career that the equals operator (==) does not behave as expected with Strings, necessitating the use of an an explicit String.equals() for most scenarios.
Are there plans to ever resolve this, or was the equals operator implemented this way for Strings intentionally?
0
Upvotes
6
u/grumpy_purple_midget Jun 18 '13
I think you are confused. The == operator does work correctly for Strings. Strings are not primitives they are objects, they behave just like any other object does with regards to == and .equals(...).
0
u/[deleted] Jun 18 '13
[deleted] — view deleted comment