You don't have a constructor for SparseMatrix
that takes a single int argument. Also, this.rows
and this.cols
are int
values, not SparseMatrix
fields. Also, you need to initialize the final
field matrix
in the constructor. You probably want this:
public class SparseMatrix {
// instance variables
private final TreeMap<Integer,TreeMap<Integer,Double>> matrix;
private final int rows;
private final int cols;
public SparseMatrix(int r, int c) {
this.rows = r;
this.cols = c;
this.matrix = new TreeMap<>();
} // end of constructor
}