ArrayList problem, help me to find out the error!

Hi, here is part of my code, after compilation, I get a Null Pointer Exception on the ORANGE part, I don't know where goes wrong.

for (int i = 0; i < N_BITS; i++){

ResultButton button = new ResultButton(0);

add(button, constraint);

resArr.add(button);

}

Note:

1. N_BITS is a just a constant.

2. resArr is an ArrayList, containing ResultButton, instance variable.

3. class ResultButton is defined by myself.

HELP ME TO FIGURE OUT THE PROBLEM, THANK YOU!

Re: ArrayList problem, help me to find out the error!

I would guess somewhere in your code you wrote a line like:

Quote:

private ArrayList<ResultButton> resArr;

...but did you ever use new on that resArr?