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

Schwartz Prince
PLUS
Schwartz Prince
Courses Plus Student 2,132 Points

Not getting the answer.

My code shows me error. Couldn't fix it.

ParsingInts.java
int answer = Integer.parseInt(answerToLife);

2 Answers

Hi there,

I think you should try again; your code looks fine. This just worked for me:

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

Steve.

Schwartz Prince
Schwartz Prince
Courses Plus Student 2,132 Points

Hi Steve,

Thank you for your response. I tried again. But, it shows the same error message.

JavaTester.java:73: error: class expected int answer = Integer.parseInt(int.answerToLife) ^

It would be great if you can help me in this.

Two things: first, don't delete the first line; make sure you have the String answerToLife = "42"; line in there. Second, don't have int.answerToLife in the second line; just use answerToLife as the parameter inside the brackets/parenteses for parseInt().

Try those. If neither works, post your whole code in and we'll get this sorted.

Steve.

:+1: :smile: