I need to implement a sparse matrix as efficiently memory-wise as I can in Java.I receive a matrix with more 0 than other values and I need to save it efficiently.I was thinking of using an array with an Object containing value and position composed of the line*max nr of columns+the column.
Depends entirely on what operations you are doing on said matrix which implementation will suit your needs.
e.g. if all you are doing is updating values and retrieving them a Map<Point, Value>
will work.
Addition is also easy in this, but multiplication becomes very difficult.