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 trialLeJacque Gillespie
3,990 Pointserror 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.
String answerToLife = "42";
String parseInt;
answerToLife = console.readLine ("42");
int age = Integer.parseInt(answerToLife);
LeJacque Gillespie
3,990 PointsI removed the space but keep getting the same error message.
Jesse James
3,020 PointsI'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!
LeJacque Gillespie
3,990 PointsThanks a lot.
John Migia
1,808 PointsHey, 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".
ISAIAH S
1,409 PointsHi LaJacque Gillespie,
Could you kindly show us your error?
That would really help,
ISAIAH S
LeJacque Gillespie
3,990 PointsHello, 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
ISAIAH S
1,409 PointsThis 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 )
Jesse James
3,020 PointsJesse James
3,020 PointsHello there!
One issue you may be having is the space between readLine and the information you're passing to it ("42").