can anyone help me,a complete newbie?

I have just started to learn java.

these days, I am always bothered by NullpointerException.

I try to pass a object to a method of its own class, but whenever

I want to read the data of that object or try to modify the content

of the object, I always get a NullpointerException. I don't know why this

happens. can some kind veteran give me a hand? here is an code encounter

this problem:

I first defined a class called matrix which mainly consist of a 2D array, "enter" is a method of this class that receive a matrix object and return a matrix object.

in main method, I first instantiate an object of the matrix class and then

pass it to the "enter " method.

matrix h=new matrix(i,j);

h=h.enter(h);

public matrix enter(matrix a) // "enter method"

{

try{

for(p=0;p<a.row;p++)

{

StreamTokenizer stok=new StreamTokenizer(br);

q=0;

while(stok.nextToken() !=';' )

{

a.matrix[p][q]=stok.nval; // the exception occurs at this line.

q++;

}

}

for(p=0;p<a.col;p++)

{

for(q=0;q<a.col;q++)

{

System.out.print(a.matrix[p][q]+ " ");

}

System.out.println();

}

} catch (IOException e) {throw e;}

return a;

}