LinkedHashSet remove duplicates object

前端 未结 5 1981
梦毁少年i
梦毁少年i 2021-01-13 06:58

I have simple question to you, I have class Product that have fields like this:

private Integer id;
private String category;
private String symbol;
private S         


        
5条回答
  •  再見小時候
    2021-01-13 07:39

    I would suggest you implement your own hash function in a way that it hashes elements with equal ID-s with the same code. This will solve your issue, without you having to code it explicitly.

提交回复
热议问题