hi there. i am trying to figure out what i am doing wrong here.

i have a class called Bag. in this class, the constructor is to create an array of type int called "x".

then i have a class called main that will call provide the interface and testing for the Bag class.

i am not declaring my Bag object correctly, though . . . i think.

also, do i need any packages imported . . . ? could that be what i am doing wrong here?

public class Bag{
private int i;
private int [] x;
private int top_pos = 0;

public Bag (){ //def. const.
i = 10;
int [] x = new int [i];
}

// method to add values to x
public void add (int val){
x[top_pos] = val;
top_pos++;
}


and then the class main is as follows . . .

public class main {
public static void main(String[] args) {
Bag b = new Bag();
b.add(5);

}

i tried making other method too. but as with the add method, when i call them, i get a null pointer exception.

i can't find an example of how to declare an array object or of an array constructor. have any?

thanks
crq
}