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 trialAbe Abdelmagid
3,181 Pointswhat is the question exactly?
I can't understand what the question is asking for
String answerToLife = console.readLine("answer");
int answer = Integer.parseInt(answerToLife);
2 Answers
Philip Gales
15,193 PointsThere are only 2 parts to the question. Let's break it down.
Create a new int variable that is named answer.
and
Store the integer version of answerToLife in it.
The first one tells us to create a new int named answer.
String answerToLife = "42"; //<---code that they gave us
int answer; //<---created a variable named answer that is an int
The second sentence tells us to store the integer version of answerToLife. Currently, it is saved as a String, so we just have to convert it to an int. You have done this, but you also added a console.readLine which is not needed since they gave us a specific String to use.
String answerToLife = "42"; //<---code that they gave us
int answer = Integer.parseInt(answerToLife); //<---asigned our answer variable the value of the String they gave us in int form
Abe Abdelmagid
3,181 PointsThank you very much
Philip Gales
15,193 PointsNo worries, be sure to mark the answer as the "best answer" by clicking the checkmark under my answer if you think it is.