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

I cannot see my syntax errors

Im getting syntax errors on my code, but the web interface wont display them... :(

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 */
    char firstLetter = lastName.charAt(0);
    if (firstLetter < 'N'){
    int line = 0;
    }else{
    int line = 1;
    }
    return line;
  }

}

3 Answers

Looks like line will be out of scope when you try to return it. Try declaring line only once before the conditional statement and just making assignments within the conditional.

EDIT: Also the function should return 1 or 2, not 0 or 1. I made that mistake myself. :P

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Thanks for the bug report, I'll figure out why! Thanks Geoff!

Yep, i pasted it into eclipse to find out why it wasn't working and exactly that!

... totally didnt spend 2 days wondering why it wasn't working.. also the web interface not showing my syntax errors (or anything at all) really didnt help :(

Having fun so far though :)

Glad you were able to get things figured out. We'll see what we can do about getting some better feedback for syntax errors.