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

where is the mistake

line 8

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 */
      if ('A' < lastNmae.chars < 'M' )
    {
      int line = 1 ;
    }
    else 
    {
    int line = 2;
    }
    int line = 0;
    return line;
    int line = 0;
    return line;
  }

}

You do not need to keep declaring the variable every time you write it. If you use a local variable inside a method just declare and initialize it once like: int line = 0; Then afterwards within the same method you can just write: line = 2; for example.

2 Answers

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,073 Points

You don't have to use ".chars" as a property, the "hint" is telling you that characters can be compared with those operators. You can use the method "str.charAt(0)" to see if the strings starts with a given letter:

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.charAt(0) < 'M') {
      line = 1;
    } else {
      line = 2;
    }

    return line;
  }

}

I hope that helps a little bit.

yp , it does thank you

It looks like your variable lastName is spelled incorrectly.