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 trialAlison Harper
1,969 PointsTrying to complete coding challenge for parsing integers
String answerToLife = "42"; Int answer = Integer.parseInt("answertoLife");
is what I have. Don't know what I'm doing wrong.
String answerToLife = "42";
Int answer = Integer.parseInt("answertoLife");
1 Answer
andren
28,558 PointsYour code is quite close, but there are a couple of small issues:
The type for an integer variable is spelled
int
notInt
. Correct capitalization is important when doing programming, to a computerint
andInt
are two completely different words even though they look quite similar to a human.You should only surround words with quote marks when you are creating a string, when you are referencing a variable you don't use quotes.
You have misspelled the name of the
answerToLife
variable. You called itanswertoLife
(you forgot to capitalize the T in To).
If you fix all of those issues like this:
String answerToLife = "42";
int answer = Integer.parseInt(answerToLife);
Then your code will pass the challenge.