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 Storing Guesses

Noelle Acheson
Noelle Acheson
610 Points

Error: cannot find symbol, and .class objects

I've noticed that others have had the same problem, and I've tried all the suggested solutions, but I'm still getting the error:

ERROR: cannot find symbol symbol: class Game location: interface Evaluation Game method$i8hofpgj3kw7e5bydnzr();

Snapshot: http://w.trhou.se/prbodtvbvo

Apparently it is a "compilation error", which means there's an error in the way I'm compiling it, or in the source code. It seems the compiler doesn't understand the class Game. But I have defined it as a public class. I tried making an object for the class (Game.class), but that doesn't help. I noticed that in between the Getting Started video and the Storing Guesses video, the Game.class and Hangman.class objects appeared on the workspace in the video? Do we need to do anything about them?


4 Answers

Christopher Augg
Christopher Augg
21,223 Points

Hello Noelle,

The error you are getting is because your Game.java file is completely empty and your Game.class file is not the correct byte code for the Game.java code provided by Dennis. I took your fork and used the java-repl to recreate your error to verify this issue. The solution is to write the code into the Game.java file as it is in the video and follow along as Dennis uses the java-repl to instantiate a Game object and test for characters. However, I am providing the code and java-repl steps below for your convenience since Dennis provided it in the video anyway. All I did to see that this works is copy the code from my workspace Game.java file and paste it into yours before running the java-repl commands. It worked great. I hope this helps.



  public class Game {
     private String mAnswer;
     private String mHits;
     private String mMisses;

     public Game(String answer) {
         mAnswer = answer;
         mHits = "";
        mMisses = "";

    public boolean applyGuess(char letter) {
         boolean isHit = mAnswer.indexOf(letter) >= 0;
         if (isHit) {
           mHits += letter;
         } else {
           mMisses += letter;
       return isHit;
treehouse:~/workspace$ java-repl                                                                 
Welcome to JavaREPL version 282 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_20)               
Type expression to evaluate, :help for more options or press tab to auto-complete.               
java> :load Game.java                                                                            
Loaded source file from Game.java                                                                
java> Game game = new Game("Treehouse")                                                          
Game game = Game@996798d                                                                         
java> game.applyGuess('t')                                                                       
java.lang.Boolean res1 = false                                                                   
java> game.applyGuess('r')                                                                       
java.lang.Boolean res2 = true                                                                    
Noelle Acheson
Noelle Acheson
610 Points

Oh my God, I never saved!! Thank you so much! Now it works! Won't make that mistake again...