Wednesday, August 22, 2012

Re: [android-developers] Issue with the basic if statement

On top of all that has been said before, the error message is actually correct.  the IF statement needs an equality operator  ( == ) , not an assignment operator ( = ) .

But in Java you aren't going to get the expected results using == on a String object... you need to use the equals() method.

if (str1.equals(str2))
    //Do something here....

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Wed, Aug 22, 2012 at 10:17 AM, lbendlin <lutz@bendlin.us> wrote:
On top of all that has been said before, the error message is actually correct.  the IF statement needs an equality operator  ( == ) , not an assignment operator ( = ) .

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment