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
Nils Garland
18,416 PointsHelp please :)
Hi, I am getting another error preventing me from continuing the Java objects course. I have posted a part of the code down below where the error is located.
public boolean promptForGuess(){
Console console = System.console();
boolean isHit = false;
boolean isValidGuess = false;
char guess = guessAsString.charAt(0);
return mGame.applyGuess(guess);
while(! isValidGuess) {
String guessAsString = console.readLine("Enter a letter: ");
char guessAsChar = guessAsString.charAt(0);
try {
isHit = mGame.applyGuess(guess);
isValidGuess = true;
} catch(IllegalArgumentException iae) {
console.printf("%s. Please try again.\n", iae.getMessage());
}
}
return isHit;
The error is this: Cannot find symbol: char guessAsChar = guessAsString.charAt(0); symbol: variable guessAsString location: class prompter
1 Answer
Jennifer Nordell
Treehouse TeacherYou're using a variable guessAsString, but you haven't defined that variable anywhere in your code above. So it doesn't know what you're referring to.
Nils Garland
18,416 PointsNils Garland
18,416 PointsOkay, that's what I thought but I looked through the video and I can't find him defining it. Thanks again and again ; )