Try ? extends T1
and ? extends T2
- this will ensure that your objects are of the same type or a subtype.
public class Pair<T1, T2> {
// Instance Fields
private T1 first;
private T2 second;
// Constructors
public Pair() {}
public Pair(Pair<? extends T1, ? extends T2> p) {
first = p.first;
second = p.second;
}
}