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 Creating the MVP Storing Guesses

Game game = new Game("treehouse"); issue in jshell

https://w.trhou.se/9ucaknd7zs snapshot of the error message " attempted to use the class Game which cannot be instanciated or its methods invoked until variable hits is declared

2 Answers

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Before you run stuff in JShell, please compile classes to see if there are any errors.

When I run javac Game.java the errors comes

  symbol:   variable hits                                                         
  location: class Game                                                            
Game.java:16: error: cannot find symbol                                           
      hits += letter;                                                             
      ^                                                                           
  symbol:   variable hits                                                         
  location: class Game                                                            
2 errors                         

Do you know how to fix the error?

I mean I can give you a hint, but if you see the error yourself and can fix it, then for learning purposes it is better that you fix and find it yourself.

Google is also there to help, error is very common.

But if you are completely stuck, just let me know, I'll give you a hint.

"Before you run stuff in JShell, please compile classes to see if there are any errors. that is totally true !!! especially for a dumb speller like me this helped. felt soo proud of myself to find 2 spelling mistakes and one missed "." after it failed to build and just followed what I've learned from this course and I'm coming from no coding background

DAMN, that feels good :) :) :) :) :) :)

Herry Suvandy
Herry Suvandy
1,745 Points

on a top of you code , you declaring you hits variable using uppercase. but on your game and applyGuess method you using a lowercase hits variable.