I keep getting this error in my code and I can't find how to fix it.
Exception in thread "main" java.lang.NullPointerException
at Field.<init>(Dam.java:73)
Here is part of the code:
class Position
{
boolean isEmpty;
Piece pHere;
int adjPos[]; // adjacent positions
void setPiece(Piece p)
{
isEmpty = false;
pHere = p;
}
Position()
{
adjPos = new int[12];
isEmpty = true;
}
}
class Field
{
Position pos[];
Field()
{
pos = new Position[13];
pos[0].adjPos[0] = 1; //error in this line
pos[0].adjPos[1] = 3;
pos[0].adjPos[2] = 5;
pos[0].adjPos[3] = 6;
}
}






