https://www.geeksforgeeks.org/difference-equals-method-java/#:~:text=equals() method for content,of values in the objects.&text=Explanation%3A Here we are creating two objects namely s1 and s2.
You're checking whether both Strings are pointing to the same memory location, as opposed to comparing their contents. Use #equals or #equalsIgnoreCase instead of ==.