The equals() method must be:
Read moreHow do you equal a string in Java?
Using String. equals() :In Java, string equals() method compares the two given strings based on the data/content of the string. If all the contents of both the strings are same then it returns true. If any character does not match, then it returns false.
Read moreWhich is better equals or == in Java?
equals() is a method of Object class. == should be used during reference comparison . == checks if both references points to same location or not. equals() method should be used for content comparison.
Read more