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

What's the proper answer to this challenge?

I have looked at another community answer, but can't figure it out.

ConferenceRegistrationAssistant.java
public class ConferenceRegistrationAssistant {

  public int getLineFor(String lastName) {
    /* If the last name is between A thru M send them to line 1
       Otherwise send them to line 2 */
    int line = 0;
    if (lastName >= 'M') {
      line = 1 ;
    } else (lastName =< 'M') {
      line = 2;
    return line;
  }

}

3 Answers

I have figured everything out thanks to another discussion.

Hey Jonathan! See my response to your question here.

Edit: (putting my response here so I can answer your question more specifically)

Notice in the challenge description that it says chars can be compared using those comparison symbols. So you will want to use the charAt() method like I described here to get the first character of the lastName string for comparison, rather than comparing a string (lastName) to a char ('M'). You are correct in using an if-else statement, but you may want to look a little closer into your if condition comparison:

lastName >= 'M'

After you change this to use the charAt() method, will you be sending the correct people to line 1 here? Remember that 'A' is less than 'M', and you'll want to send people with last names between A thru M to line 1.

Also, one last thing to note is that you don't need to put a condition for your else statement. However, if you wanted to specify a condition, you would need to put else if (condition).

Hope this helps!

I'm still not sure I follow.

Can you elaborate on which part you're confused about?

I'm not sure where to put my charAt() method.