Java Interview Questions
What is the difference between == and equals() while comparing strings? Which one is reliable?
== operator compares the references of the String objects. It doesn’t compare the contents of the objects. equals() method compares the contents. While comparing the strings, equals() method should be used as it yields the correct results.