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 trialSam Detnon
1,363 PointsI 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;
}else{
int line = 1;
}
return line;
}
}
3 Answers
Geoff Parsons
11,679 PointsLooks 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
Treehouse TeacherThanks for the bug report, I'll figure out why! Thanks Geoff!
Sam Detnon
1,363 PointsYep, 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 :)
Geoff Parsons
11,679 PointsGlad you were able to get things figured out. We'll see what we can do about getting some better feedback for syntax errors.