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 trialadriantennison
3,090 PointsHow to check the lastName with the if statement
How to compile this
public class ConferenceRegistrationAssistant {
public int getLineFor(String lastName) {
if(indexOf(lastName)= "[A-M]"){
int line = 0;
return line;
}
else
{
int line=1;
return line;
}
}
}
1 Answer
Leen Leenaerts
1,096 PointsindexOf(lastName)= "[A-M]"
indexOf(...) gives you an integer, it can never be equals to a String. To make it shorter you can just return 0 or 1 and get rid of the variable line, it only makes your code more complicated I don't know what you want to do with your code, if you tell me I can probably help you further.