+ 3
Como comparar dos variables de tipo String en java?.
Si comparo dos String con el mismo texto mediante == porque no me da true?
1 Answer
+ 13
The "==" operator compares the value of two object references to see whether they refer to the same String instance while the equals() method compares the "value" inside String instances (on the heap) irrespective of the two object references refer to the same String instance or not.
P.S. That's the reason why "==" resulted in false! You should use the equals() method when comparing two Strings.