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

Compile error - Symbol not found - Cannot see one method in imported package  RSS feed

 
Christopher.T Brown
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a newbie project and I have a problem I cannot resolve. I have deleted the Netbeans cache, recreated the problem child, and turned on/off Compile on Save(?). The problem is this: The setCell method is not seen in the BoardGameTester. I get "Symbol not found". I am going to post the problem code and the error message. Thanks in advance for your time and any help in advance. PS- Please be kind as I am new to this site. If I have posted the code incorrectly, just let me know how to do it and I will repost.

Error:
run:
Tic Tac Toe game board
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: Array.setCell
at boardgametester.BoardGameTester.main(BoardGameTester.java:32)
C:\Users\Chris\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 5 seconds)

Code:

 
Vijay Vishwa
Ranch Hand
Posts: 40
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reason why setCell method is not found because you have declared Board variables as array

I am sure that you do not intend to declare Board array, instead you want create Board object
try


Hope this would solve your problem
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Ask yourself this question: What type of object is tttBoard

Hint:
Car is an object.
Car can be started
A collection of cars is called a parking lot
A parking lot cannot be started
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Another minor point: Don't use \n (even though you seem to find it in all the books). The \n character is platform‑dependent and is not actually correct for Windows®. Use this (not available on Java6) instead.
 
Christopher.T Brown
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, fellas. Vijay, you were right on the money. It fixed that error. I have since fixed an OutOfBoundsException on the array. I now have a NullPointerException. I have researched the issue, and what I've learned is that I'm referencing an object that doesn't exists. I cannot figure out what object it may be. So, here's my code and the compile error. Thanks again!





Error:
run:
Tic Tac Toe game board


Connect Four game board
Exception in thread "main" java.lang.NullPointerException
at games.board.Board.toString(Board.java:47)
at boardgametester.BoardGameTester.main(BoardGameTester.java:37)
C:\Users\Chris\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't see how you can get such an Exception from line 47; maybe the line numbers are different.

Don't write toString after System.out.print(...);
Not
System.out.println(tttBoard.toString());
but
System.out.println(tttBoard);
That calls toString behind the scenes so toString is unnecessary. If your reference happens to be null (but I cannot see it being null there) you will suffer an Exception. If you miss out toString() it will print null for a null.

I put code tags and a few spaces round your output; that is how to get it to appear correctly.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!