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 Basics Perfecting the Prototype Parsing Integers

Trying 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.

ParsingInts.java
String answerToLife = "42";
Int answer = Integer.parseInt("answertoLife");

1 Answer

andren
andren
28,558 Points

Your code is quite close, but there are a couple of small issues:

  1. The type for an integer variable is spelled int not Int. Correct capitalization is important when doing programming, to a computer int and Int are two completely different words even though they look quite similar to a human.

  2. 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.

  3. You have misspelled the name of the answerToLife variable. You called it answertoLife (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.