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

error message

I am running this code:

String answerToLife = "42"; String parseInt; answerToLife = console.readLine ("42"); int age = Integer.parseInt(answerToLife);

and keep getting an error message on the "c" in console on the third line.

ParsingInts.java
String answerToLife = "42";
String parseInt;
answerToLife = console.readLine ("42");
int age = Integer.parseInt(answerToLife);
Jesse James
Jesse James
3,020 Points

Hello there!

One issue you may be having is the space between readLine and the information you're passing to it ("42").

I removed the space but keep getting the same error message.

Jesse James
Jesse James
3,020 Points

I'm on my way home from work but I'll take a look as soon as I get home :). We'll tackle this by the end of the night!

Thanks a lot.

John Migia
John Migia
1,808 Points

Hey, Not too sure if it will fix your issue, but you might have to rename your variable name on line # 2 to something else other than "parseInt".

Hi LaJacque Gillespie,

Could you kindly show us your error?

That would really help,

ISAIAH S

Hello, I have taken the advice given and reqritten the code but keep getting this error:

JavaTester.java:43: error: cannot find symbol answerToLife = console.readLine("42"); ^ symbol: variable console location: class JavaTester 1 error

I removed the last line of the code shown above, taken away the space after readLine, and removed the String parseInt line as well, but keep getting this same message.

Thanks a lot.

1 Answer

This is how I edited your code so it works:

import java.io.Console;

public class ParsingInts {

 public static void main(String[] args) {
Console console = System.console();
String answerToLife = "42";
String parseInt;
answerToLife = console.readLine("42");}}

As you see, you have to define what "console" means. ( line 6 )