0

ok heres the code im working with..

 public boolean legalMove(int row, int column)
    {

        if (a.empty(row, column) == true)
        {
            System.out.println("This sqaure is empty");
            return false;
        }
    }

now my empty method header looks like ..

  public boolean empty(int row, int column)

and the code inside for empty() works. now in the method legalMove(), i have a.empty(row, column) and when i go to compile it it says "cannot find symbol - method empty(int, int)". a is a 2d array.

why is this? how come i cant call empty() inside of legalMove(), they are both within the same class. any help appreciated. theres a seperate driver class too, but that shoulden't matter.

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ezzaral
0

A 2D array doesn't have a method called empty(), which is what you are trying to call here a.empty(row,column) . You don't show your empty() method, but if it already operates on an instance level array variable, just call emtpy(row,column) . If you need that method to work against different arrays when called, you need to pass the array as a parameter to the method along with the row and column.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.