Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build an Interactive Story App (Retired) Intents and Multiple Activities Introducing String Resources

not a statement

name == "Friend"; is underlined red and says not a statement

  if (name == null){
            name == "Friend";

The == operator cannot be use in that way. are you trying to compare strings? if yes, you should use the .comparesTo() method. Read this

1 Answer

Hi Tegh,

The double equals operator (==) is checking for equality, like Francisco mentions. In the video, however, the code is using a single equals (=) which is the assignment operator.

It basically reads like this: if name is null, then assign to name the value of "Friend"


Thanks a lot Robert Richey