I want to implement some algorithm:
public class MaximumSubarrayAlgorithm<TArray extends List<T>, T extends Comparable<T>>
{
public void DoSmth(TArray simple) {
T t1 = simple.get(0);
T t2 = simple.get(1);
t1 = t1 + t2; // wrong: The operator + is undefined for the argument type(s) T, T
return null;
}
}
How to require possibility to add instances of type parameters (and tell it to java compiler)? May be T is not Integer, it may be some other type, that support addition.