This question shows research effort; it is useful and clear
5
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
有没有办法强制java泛型中的类型参数实现equals方法?比如我写了这个类:public class Bag<Item> implements Iterable<Item>which has containsmethod, that uses Item.equalsmethod。所以我想确保泛型中传递的 Object 也将实现该equals方法。