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!

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

What should I do after the if/else statement?

I wrote the if/else code, but I'm not really sure what to do next...

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;

    if (lastName < 'M') {

    } else {




2 Answers

In this challenge you are supposed to determine if the first letter of their last name is less than or equal to 'M' so you should use the .charAt() method to check the first letter of their last name. Then you want to set the line variable to 1 if it is less than or equal to 'M', else set line equal to 2.

Justin Carothers
Justin Carothers
12,598 Points
if (lastName.charAt(0)  < 'M') {

You may later need to chage the string toUpperCase()