Wednesday, April 3, 2013

why string is not compare using double equal sign [closed]

java - why string is not compare using double equal sign - Stack Overflow



















Why string is not comparable using ==. Why we must use isEqualToString for compare two strings.


Thanks in advance



















It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.















becouse with == you compare the object references and with equalsIgnoreCase() the values of the String objects.























The way the == operator works in java is as follows:


  • Compare values for primitive types, such as doubles, ints, etc.

  • Compare the location in memory for objects (in other words, it has to be the same object it can't just look the same at a given moment). Since String is an object and not a primitive type, the latter rule applies.

Here is the source:


http://stevenrbrandt.com/cios/index.php/strings.xml


Hope it helps.












Not the answer you're looking for? Browse other questions tagged or ask your own question.






lang-java






.

forum.xda-developers.com

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...