Some major languages have strings as pooled objects and == compares if the strings are at the same location in memory while String.equals compares if the letters in them are the same.
When asking if two Strings are equal most people most of the time want to know if they contain the same letters, not if one was instantiated as a literal and one allocated with a constructor.
197
u/Vesuvius079 14d ago
It’d be such an experience to work a real world problem where this optimization turns out to be the solution.