I hava a generic class called ArrayBag. I want to override equals method. So i wrote
public boolean equals(T other){
} // gives error
error message: Name clash: The method equals(T) of type ArrayBag has the same erasure as equals(Object) of type Object but does not
override it
The equals method you are trying to override expects an
Object. When your code is translated to byte code, type erasure transforms yourTinto anObject, which conflicts with the existing equals method.Inside the method you can handle casting to
T.