Java – find duplicate entries in the collection
•
Java
Is there a tool or library that can find duplicate entries in the collection according to specific standards that can be implemented?
In order to make myself clear: I want to compare items with each other according to specific criteria So I think a predicate that only returns true or false is not enough
I can't use equality
Solution
This depends on the semantics of the standard:
If your standards are always the same for a given class and are inherent in the underlying concepts, you should implement equals and hashcode and use a collection
If your criteria depend on the context, org apache. commons. collections. CollectionUtils. Select (Java. Util. Collection, org. Apache. Commons. Collections. Predict) may be your correct solution
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码