Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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... :(

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;
    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
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.