aspose file tools*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot find symbol message" Watch "Cannot find symbol message" New topic
Author

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
one.setName("Adam");

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.

Thanks

Joe

This is the code for my GamePlay class



This is the code for my Player class:



OCPJP 85%
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
Sheriff

Joined: Oct 13, 2005
Posts: 39784
    
  28
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: http://aspose.com/file-tools
 
subject: Cannot find symbol message