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

后端 未结 21 1646
渐次进展
渐次进展 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:33

    You can use distinct to remove duplicates

    List blogList = ....// add your list here
    
    blogList.stream().distinct().collect(Collectors.toList());
    
    

提交回复
热议问题