I know that ==
has some issues when comparing two Strings
. It seems that String.equals()
is a better approach. Well, I\'m doing JUni
In a nutshell - you can have two String objects that contain the same characters but are different objects (in different memory locations). The == operator checks to see that two references are pointing to the same object (memory location), but the equals() method checks if the characters are the same.
Usually you are interested in checking if two Strings contain the same characters, not whether they point to the same memory location.