I\'m attempting implement the add method mentioned in the Generic sparse matrix addition question
class Matrix
{
private T add(T left,
"I'm not sure what I'm missing since T extends Number and Integer is a subclass of Number."
This statement is false. In general if you have:
public class B extends A {
}
public class C extends A {
}
it does not mean that B can be cast to C. So writing something like:
public T method(T arg) {
return (B)arg;
}
and you calling it with B b = (B)method(C);
is obviously wrong.