Not all “String in Java are interned”. Try reading something from a file or console, those Strings aren’t “interned”, thus equals()
(and also hashcode()
) needs to be overriden.
1
solved What is the need to override equals method in String class? [closed]