I'm getting a null pointer exception on the following code (part of a larger program - the exception is thrown on the line where "add" is called).
public class A
{
static ArrayList<Integer> sets[];
public static void main(String[] args)
{
sets = new ArrayList[5];
sets[0].add(1);
}
}
I also do not understand why the compiler is requiring me to make any class level variables static (e.g. the ArrayList). As far as I can tell, these things shouldn't be in a static context (in terms of coding practice, not compiler problems) and yet the compiler is requiring it.
Thanks in advance.