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 trialJonathan Weinstein
9,063 PointsAnyone know what the problem with "console" is here?
Here's my code for reference. Keeps getting errors on the System.console part.
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 (lastName.charAt(0) <= 'M') {
System.console.println("Go to line 1");
} else {
System.console.println("Go to line 2");
}
}
}
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;
return line;
}
}
1 Answer
Ken Alger
Treehouse TeacherJonathan;
A couple of things.
1) The challenge isn't asking for any output, and as such a Console object has not been created, thus causing your specific errors.
2) Your getLineFor()
method is supposed to be returning an int
value. Right now you are not returning anything.
3) Your if... else statement looks good, you just need to do something other than print output. HINT The prompting code has an int
variable defined and is returning it. Perhaps in the if... else statement you can do something with that variable???
Post back if you are still stuck.
Happy coding,
Ken
Jonathan Weinstein
9,063 PointsJonathan Weinstein
9,063 PointsGot it! Thanks for pointing me in the right direction.