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 need some help in this challenge. Can't get through!!

Can anyone help me with the command line for this challenge with an explanation? Thanks in advance.

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 */
    int line = 0;
    return line;
  }

}
Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hey Shivang I just started at work but I'll answer this more in depth when I get home.

Remember that we can compare the first character in words with.

lastName.charAt(0) < "M"

We can put this in an if statement and move them to the correct line. So if the above line of code is true. They'd go to line. 1 sorry I can't type the whole thing out on my phone.

Hi Rob,

I really appreciate your quick response. Will try to work things out with what you have suggested. Please do reply back once you get back home. Have a happy working day!! :)

Hey Rob,

It worked out fine. Finally did it. Thanks a ton!!

1 Answer

J.D. Sandifer
J.D. Sandifer
18,813 Points

Use .charAt(0) on a String to get the first letter. This can be compared with other letters as required to sort the Strings.