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 Objects (Retired) Creating the MVP Prompting for Guesses

Arshan Khanifar
Arshan Khanifar
11,497 Points

I've imported java.io.console but it still can't find symbol!

Hey everyone! I was just following along with the course and when I wanted to compile the code, the prompter.java won't compile and it says : ./Prompter.java:11: error: cannot find symbol
Console console = new System.console();
I have already imported java.io.console so I really don't know where the problem is! :/

this is my whole prompter class:

public class Prompter { private Game mGame; public Prompter(Game game) { mGame = game ; }

public boolean promptForGuess() {

Console console = new System.console();
String guessAsString = console.readLine("Please enter a character:  ");
char guess = guessAsString.charAt(0);
return mGame.applyGuess(guess);

}

}

Arshan Khanifar
Arshan Khanifar
11,497 Points

and btw can someone teach me how to post my code here so the whole code gets into the grey area? I'm just copying and pasting it but I what I see now is that only the Console console = new System.console(); and a couple of lines after that goes into the grey area! :/

1 Answer

Hello Arshan,

Firstly, make sure that you import the java.io.Console (be careful because, Äąt is case sensitive)

Secondly, you can not use "new" keyword while you constructing a new console object. (Note: And if you want to create new console object, it should be in a static method such as main.)

So this line

"Console console = new System.console();" should be like below: Console console = System.console();