In Java the == compares two objects by identity. If you want to
compare two objects by value you must use the equals() method.
Comparing two Strings thus becomes: stringA.equals(stringB). It is
possible to use == with strings but it requires a good understanding
of how they work internally and a good understanding of the notion of
String interning. It's also very easy to get wrong :) Note that one of
the first things equals() does is check if the two objects have the
same identity (using ==).

On Mon, Jun 9, 2008 at 8:47 AM, Chris B. <[EMAIL PROTECTED]> wrote:
>
> I would like to know if it is possible to compare two different
> EditTexts using a if...else statement.  I am trying to compare them
> with this template:
>
> if(<name>.getText() == <anotherName>.getText()){
> //code
> }
> else {
> //more code
> }
>
> No matter what i always get the else block of code even if i display
> my answer and the correct one and they are obviously the same.  Is
> there another comparison method or is my code wrong?
> >
>



-- 
Romain Guy
www.curious-creature.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to