What I am trying to do is add an element to an ArrayList each time a method is called.
public class Dice
{
private static int x3;
private static ArrayList<Integer> totals;
public Dice()
{
totals = new ArrayList<Integer>();
}
public static void Roll()
{
int x1 = (int)(Math.random()*6)+1;
int x2 = (int)(Math.random()*6)+1;
x3 = x1 + x2;
totals.add(x3);
}
}
Every time the Roll() method is called, I receive a Null Pointer Error for "totals.add(x3);"
Any ideas?