Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot find symbol  RSS feed

 
Dan Broadwater
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help with Tic Tac Toe Game.  I have two items saying cannot find symbol.   1.  createBoard  2.  winOrTie .  Would you please help me find out what is wrong?


 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan Broadwater wrote: I have two items saying cannot find symbol.   1.  createBoard  2.  winOrTie .  Would you please help me find out what is wrong?


Can you show us the createBoard() and winOrTie() methods?

Henry
 
Campbell Ritchie
Marshal
Posts: 55681
162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please always put code inside code tags; since you are new I shall do it for you and you will see how much better it looks You cannot get coloured text inside code tags; anyway the pink text is really difficult to read, sp I shall have to take all colours off.
Beware of @SuppressWarnings, even when Eclipse suggests it. It would be better to find the empty statement and get rid of it. If it isn't a contradiction in terms to get rid of nothing. As Henry says, where are those two identifiers declared?
 
Campbell Ritchie
Marshal
Posts: 55681
162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are they methods of variables. One has () and the other doesn't have ().
 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These lines confuse me:

You declare `winOrTie` as a variable of type int, then call a method that has the same name.

It would help if you showed the full code.
 
Dan Broadwater
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using netbeans, and I have two problems with cannot find symbol, I marked them with //cannot find symbol.


        
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

As already mentioned...

Henry Wong wrote:
Can you show us the createBoard() and winOrTie() methods?


The compiler is complaining that it can't find those methods? Did you implement them yet?

Henry
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Cannot find symbol" means that you are using a name (of a method, or a variable) that the compiler doesn't know about.

For example, if a method call to the method createBoard(3, 3) causes this error, then that means that there is no createBoard method. Either you spelled the name of the method wrong, or you forgot to add that method to the class, or you are calling it the wrong way (is the method in another class?).
 
Dan Broadwater
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure of what you are asking.
 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure of what you are asking.

He is asking you to show us the code for the createBoard() method that your program is calling at line 19.
 
Dan Broadwater
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is all I have for now


 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan Broadwater wrote:this is all I have for now


The compiler is complaining that it can't find the createBoard() and winOrTie() methods of the TicTacToeGames class. If those methods don't exist, that is the reason for the compiler error. You need to implement those methods. Or don't call those non-existent methods.

Henry
 
salvin francis
Bartender
Posts: 1591
35
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan Broadwater wrote:this is all I have for now

Hi, I think what Henry means above is that your code is incomplete.

Besides this, I also see that you have used numbers to indicate empty/cross, etc. I would advise against it.
Have a look at a similar question about this game in another post:
https://coderanch.com/t/669292/java/Created-Tic-Tac-Toe-Java
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your formatting of your program is awful.  This is not just annoying, but in fact, a bug -- even if your code executes correctly.  In Netbeans just press Ctrl-Alt-F (for Windows, at least) and follow the Style guide.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan Broadwater wrote:I am not sure of what you are asking.

If you are not sure of what our questions mean, then maybe you should go a step back and make sure you understand the basics of programming in Java before attempting to write a longer and more complicated program.

The Oracle Java Tutorials are a good place to learn the basics. Make sure you how understand classes, variables and methods work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!