My suggestion is to create a Matrix class, so you can easily have multiple matrix objects.
Java: | class Matrix<T>
{
private int rows, cols;
private T [][] data;
public Matrix (int cols, int rows )
{
this. rows = rows;
this. cols = cols;
// array initialization
}
public Matrix (int cols, int rows, T default )
{
this. rows = rows;
this. cols = cols;
// array initialization with default value
}
public int getRows ()
{
}
public int getCols ()
{
}
public T at (int row, int col )
{
return data [row ][col ];
}
public void setAt (int row, int col, T value )
{
data [row ][col ] = value;
}
public String toString ()
{
}
} |
|