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 trialMonique Maree
Courses Plus Student 1,961 PointsStuck in a challenge task
Please help me with this question, been stuck on it for a while:
Create a new int variable that is named answer. Store the integer version of answerToLife in it.
3 Answers
Szymon Kadłuczka
8,762 PointsI didn't take this course, but I think the correct answer should be:
int answer = Integer.parseInt(answerToLife);
Stephen Bone
12,359 PointsHi Monique
You basically need to convert the string variable to an integer and store it in a variable of int type.
In the previous video Craig discusses using the Integer wrapper with the parseInt method to handle the conversion.
So your code should look as below:
int answer = Integer.parseInt(answerToLife);
Hope it helps!
Monique Maree
Courses Plus Student 1,961 PointsThank you :)
Jeff Busch
19,287 PointsJeff Busch
19,287 PointsCan we see your code?