Error: Cannot find ArrayList character

I am trying to create some kind of list to store values ​​from an array table. (I use arraylist here, but should I use a list instead?) However, every time I try to compile, it throws the following error:

cannot find symbol symbol: class ArrayList location: class players.TablePlayer

The code is below.

public class TablePlayer extends Player {

    int[][] table;
    ArrayList goodMoves;


    public TablePlayer(String name) {
        super(name);
    }

    @Override
    public int move() {
        int oppLast = opponentLastMove();
        int myLast = myLastMove();
        if (!isLegalMove(oppLast)) {
            return 0; // temporary
        }
        if (wonLast()) {
            table[oppLast][myLast] = 1;
            table[myLast][oppLast] = -1;
        }
        if ((wonLast() == false) && (oppLast != myLast)) {
            table[oppLast][myLast] = -1;
            table[myLast][oppLast] = 1;
        }
        for (int i = 0; i < table.length; i++) {
            for (int j = 0; j < table.length; j++) {
                if (table[i][j] == 1) {
                    goodMoves.add(table[i][j]);
                }
            }
        }

        return oppLast; // temporary
    }

    @Override
    public void start() {
        int[][] table = new int[7][7];
        ArrayList<int> goodMoves = new ArrayList<int>();
    }
}

Any help would be great, thanks!

+5
source share
2 answers

Do you have an import statement at the top of the file?

import java.util.ArrayList;
+14
source

Before using a class, you need to import it into the class definition.

Add it on top of the file:

import java.util.ArrayList;

For more information on imports, see here.

, IDE, Eclipse, Netbeans. , Java ( ) .

0

All Articles