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! While you're at it, check out some resources Treehouse students have shared here.

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

Java Java Objects (Retired) Creating the MVP Comparing Characters

How to check the lastName with the if statement

How to compile this

ConferenceRegistrationAssistant.java
public class ConferenceRegistrationAssistant {

  public int getLineFor(String lastName) {

    if(indexOf(lastName)= "[A-M]"){
    int line = 0;
    return line;
    }
    else
    {
 int line=1;
      return line;
    }
  }

}

1 Answer

Leen Leenaerts
Leen Leenaerts
1,096 Points

indexOf(lastName)= "[A-M]"

indexOf(...) gives you an integer, it can never be equals to a String. To make it shorter you can just return 0 or 1 and get rid of the variable line, it only makes your code more complicated I don't know what you want to do with your code, if you tell me I can probably help you further.