I have the following code:
public abstract class A<T extends B<? extends A<T>>>{
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
A other = (A) obj; // warning here: "A is a raw type"
// [...]
}
}
How to avoid both “A is a raw type” and “Type safety: unchecked cast” at the specified line? Is there a hack of some sort or I am doing something wrong with my classes?
Thanks
If the parameterized type of the compared
Adoesn’t matter, declare and cast it asA<?>:This will remove the warning.