• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error: cannot find symbol in SimpleDotCom exercise from Head First Java  RSS feed

 
Sasha Kang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am learning Java from Head First Java book
there is an exercise there called SimpleDotCom
i get an error:
===========
SimpleDotComMain.java:11: error: cannot find symbol
            String guess = helper.getUserInput("enter a number");
                                 ^
  symbol:   method getUserInput(String)
  location: variable helper of type GameHelper
1 error
===========

and i can't figure out why i keep getting it


and here is the GameHelper class:


GameHelper class compiles fine.
The  SimpleDotComMain just copied from the book.
Any advice?
 
Campbell Ritchie
Marshal
Posts: 56585
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I think you have a minor spelling error; getUserInput vs getUserlnput. I/lowercase L.
 
Sasha Kang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how stupid of me
thanks man!
 
Campbell Ritchie
Marshal
Posts: 56585
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think nothing of it. Lots of people make that sort of mistake.
 
Randy Maddocks
Ranch Hand
Posts: 184
4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sasha,

This is off-topic, but where you have the statement:



You can simplify it to just:



You have already initiated the value boolean isAlive in the previous statement (line 9). Using the "==" operator in such circumstances has the risk of it becoming an assignment statement (e.g. isAlive = true), instead of an expression. The "==" operator is for checking if the values of two operands are equal or not.

All the best.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!