My course says that having a generic MyClass<T>, if we have two objects MyClass<A> and MyClass<B> there is no relationship between them regardless if A and B are related and that the common parent is Object.
What I'm trying to do is implement my own Pair<T, U> and I'm a bit confused on how to implement equals because until now I'd do something like
...
if(!(obj instanceof MyClass)) return false;
...
As far as I understood I can't do this for generics, right? because their common parent is object and if I tried casting to a Pair <T, U> I could get an error at run time.
What's the proper way to write an equals() for a generic with 1, 2 or multiple types? Should I check getClass() != obj.getClass() instead?