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

int answer = Integer.parsInt(answerToLife);

I've been stuck here for days please someone help me and tell me what I am doing wrong...

ParsingInts.java
int answer = 35; 
int answer = Integer.parsInt(answerToLife);
Craig Dennis
Craig Dennis
Treehouse Teacher

Are you still stuck or did christopher vaughan help? If so, please make sure you click the best answer so that he gets the points he deserves! Thanks!

1 Answer

two things ( maybe 1)

1) you don't show the declaration of answerToLife. If you just left that line off, then ignore this. otherwise add that back in.

2) in the second line you misspelled parseInt(parsInt) & you are redeclaring the variable with that second int declaration. see corrected code below:

String answerToLife = "42";
int answer = 35; 
 answer = Integer.parseInt(answerToLife);