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 trialJoseph Jaber
646 PointsDereference Error
This question doesn't state that we are assuming the characters are upper-or-lower cases. So to be safe I want to convert the letter to upper case using this code: lastName.charAt(0).toUpperCase()
Problem is this gives me a dereference error message. I don't see why this shouldn't work.
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).toUpperCase() <= 'M'){
return 1;
}
else{
return 2;
}
}
}
1 Answer
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsSo when you use chaining, be sure to read it from inside to the outside.
You are starting with a String then calling charAt(0) which is returning the 1st Character of the String. But the return Type is now Char NOT String. Char and String both use a method called toUpperCase but they work slightly different.
If you look at the method toUpperCase under each doc. You will see that slight difference.
Let me know if this hint helps or if you are still stuck.
Joseph Jaber
646 PointsJoseph Jaber
646 PointsThanks for the help! But I still can't seem to find a solution to what I'm doing. Is there maybe a similar method to "toUpperCase" that is for chars?