How to remove duplicate objects in a List without equals/hashcode?

后端 未结 21 1648
渐次进展
渐次进展 2020-12-03 02:53

I have to remove duplicated objects in a List. It is a List from the object Blog that looks like this:

public class Blog {
    private String title;
    priv         


        
21条回答
  •  醉酒成梦
    2020-12-03 03:31

    You could override the equals() method, with title, author, url and description. (and the hashCode() since if you override one you should override the other). Then use a HashSet of type .

提交回复
热议问题