At the moment I am trying to do the matrix in an array. You see I am not very good at

Java and don't knoiw much about. Maybe I shouldn't be using an array- if that is the case could you suggest some alternative structures please.

At the moment this is what I have come up with:

int row1= rsmd.getRowCount(), row2= rsmd.getRowCount();

int[][] distanceMatrix;

distanceMatrix= new int [row1][row2];

/*This produces a matrix with the same number of column as rows. The size of the matrix changes since it stores some calculations that have been carried out on database rows. As a result the number of rows that the database has is called for and this determines the size of the matrix.*/

My problems begin after this. I could say that if the row number is equal to the column number then place a 0 in this element.ie, for a 2*2 matrix if row number is 1 and column number is 1 then put a 0 there. (I don't know how to code this).

I could also say that if the column number(for the column that we are considering) is greater than the row number(for the row we are considering )then leave the element blank. Again I don't know how I would code this.

I could then enter the values into the remaining array elements. However, this is also difficult because all the calculation values are placed into an array (which then need to be put into the matrix). The fact that the size of the matrix varies depending on the database makes this difficult.

Please help- I really have no idea as to how I can do this.