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

San Francisco
San Francisco
28,373 Points

Getting an error although my code seems to be exactly what is in the video example.

Not sure why I'm getting this error:

treehouse:~/workspace$ javac Hangman.java
./Prompter.java:15: error: reached end of file while parsing
}
^
1 error

Here is my code:

public class Hangman {

    public static void main(String[] args) {
        // Enter amazing code here:
      Game game = new Game("treehouse");
      Prompter prompter = new Prompter(game);
      boolean isHit = prompter.promptForGuess();
      if (isHit) {
        System.out.println("We got a hit!");
      } else {
        System.out.println("Nope");
      }
    }

}

'''

2 Answers

Wesley Seago
Wesley Seago
10,424 Points

error: reached end of file while parsing

is a problem with your curly braces. From the code posted, you have the correct opening and closing braces, but I suspect if you examine the entire file, you will find an errant brace somewhere.

Also, I have found the workspace to be a little buggy at times myself. Make sure everything is saved before you run it.

Craig Dennis
Craig Dennis
Treehouse Teacher

Also note the error is in the Prompter file!

San Francisco
San Francisco
28,373 Points

Woah, totally missed the fact that this was in the promptor file...while it is staring right at me! lol...thanks guys!