This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Cannot find symbol message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot find symbol message" Watch "Cannot find symbol message" New topic

Cannot find symbol message

Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Hi there,

I'm getting an annoying cannot find symbol message when trying to compile my 'GamePlayer' class. The message reads:

cannot find symbol
symbol : method setName(java.lang.String)
location : class Player

the pointer points to the point full stop before setName. The message repeats for every one of my Player objects.

I can't quite see what I'm doing wrong and would be grateful for any help.



This is the code for my GamePlay class

This is the code for my Player class:

Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Sorry everyone. Please don't spend any time on this, I'm just being an idiot. When I changed my Player class to include the setName method, I forgot to recompile it. Doh!
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Joe Lemmer:
I forgot to recompile it.

no problem. it is a common mistake
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 44433
Probably better to set the name in the constructorThen you don't need the setName method, unless you think your Players will change their names in mid-game!
I agree. Here's the link:
subject: Cannot find symbol message
It's not a secret anymore!