I am trying to create a matrix library (educational goal) and have reached a barrier. I'm not sure how to approach with grace. Adding two matrices is a simple task using the get () method for each element of each matrix.
However, the syntax I used is incorrect. NetBeans claims to be expecting a class, but has detected a type parameter; for me, a type parameter is just a set with a 1: 1 mapping to a set of classes.
Why am I wrong here? I have never seen a type parameter be anything other than a class before, so should the next bit not imply that M is a class?
M expands the matrix
public abstract class Matrix<T extends Number, M extends Matrix>
{
private int rows, cols;
public Matrix(int rows, int cols)
{
this.rows = rows;
this.cols = cols;
}
public M plus(Matrix other)
{
M result = new M(2, 2);
}
public abstract T get(int row, int col);
public abstract void set(int row, int col, T val);
}