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 trialkevinlibertino
Courses Plus Student 315 PointsHow do I Create a new int variable that is named answer. Store the integer version of answerToLife in it?
I'm not too sure how to store the integer version in my int variable.
int answer = answerToLife;
String answerToLife = "42";
1 Answer
Ken Alger
Treehouse TeacherKevin;
At the moment your code will cause some errors as you are attempting to assign a String value to an int type, and defining your String value after the assignment. You might try something along the lines of:
String answerToLife = "42";
int answer = Integer.parseInt(answerToLife);
Hopefully that is what you are attempting to do.
Happy coding,
Ken