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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Tyler Combs](https://uploads.teamtreehouse.com/production/profile-photos/6715592/micro_profile-photo-wedding.jpg)
Tyler Combs
15,525 PointsNot sure if this is a bug, but I can't interact with the application after compiling and running.
I'm fairly certain my code is exactly like Craig's in the video. I'm not getting any compiler errors or anything. After entering clear && javac Hangman.java && java Hangman
, the console goes blank and when I enter things, nothing happens. I have to use ctrl+c to exit. I know it compiles and runs successfully because I get those little stamps that appear after compiling and executing completes. What's happening?
Edit: Here's a snapshot of my workspace if needed. https://w.trhou.se/nsh4014tlb
1 Answer
![Seth Kroger](https://secure.gravatar.com/avatar/b5bdc43c1e576145fb404edba6fea5a6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Seth Kroger
56,413 PointsOhh and it's just the tiniest little thing too. In Prompter.java your while loop has an extraneous semi-colon:
public void play() {
while (mGame.getRemainingTries() > 0); {
// --------------------------------^
displayProgress();
promptForGuess();
}
Using a semi-colon there creates a empty block for the while loop, and since the empty block does nothing it creates an infinite loop. It is technically valid syntax because a single expression and a curly-brace block are equivalent and nothing prevents an empty expression. But it is still an error because the loop does nothing forever.
Tyler Combs
15,525 PointsTyler Combs
15,525 PointsThanks so much for the help! Seems like my biggest problem so far is learning the syntax. Would it be safe to assume that every time this happens, I managed to create an infinite loop? Or does this also happen because of other things?