I\'m trying to override equals
method for a parameterized class.
@Override
public boolean equals(Object obj) {
if (this == obj)
return t
Off-topic - do you realise that according to your implementation, Tuple(a0, a1) is equal to Tuple(a1, a1)? I suspect that's not what you want...
On-topic, as others have said, erasure makes this impossible. But you should reconsider why you want this - equality checking only happens at runtime, and generics are only compile-time. Conceptually, a variable has generic parameters, but an object does not. Thus when you're comparing the equality of objects, the generic parameters do not matter at all; you can't take any appropriate action based on them at runtime anyway.
Object equality, and generic parameter co-/contra-variance, are two orthogonal concerns.