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

Abe Daniels
PLUS
Abe Daniels
Courses Plus Student 2,781 Points

So close yet so far.

No errors, correct formula, and yet here I am being told that it's not returning the proper line. I've also tried to set the integer of line to 0 and 1 instead of 1 and 2. That didn't seem to do the trick either. I've troubleshot my code until I couldn't any further. Somebody point out the small mistake I'm making for me xD thanks!

ConferenceRegistrationAssistant.java
public class ConferenceRegistrationAssistant {
  int line;
  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 (lastName.charAt(0) < 'm') {
      int line = 1;
    } else {
      int line = 2;
    }
      return line;
  }

}

2 Answers

You're declaring the line variable more than once. Remove 'int' from your statements assigning 1 or 2 to line and it should work.

Also since you're dealing with the first letter of their last name, you should be using an uppercase M in your if statement condition.

Abe Daniels
Abe Daniels
Courses Plus Student 2,781 Points

I did both of these things but the website still returned "I entered Anderson and expected to get back line 1 as A comes before M." Even though I do know you are right about the "int" and the lowercase 'M." Now I'm totally blown away that it isn't working haha.

Abe Daniels
PLUS
Abe Daniels
Courses Plus Student 2,781 Points

The page was broken. Your solution worked after I hit "check answer" a few times. Thank you!