Posted In: Java Core, Set

How to remove duplicate objects while adding to Collection and Sort – Example2

Use case – We have list of objects (in this case users). We want to remove duplicate users depending on some criteria. Then sort them. In this example with first name. Both of this can be achieved by overriding equals and Comparable.compareTo methods. Result [User [age=35, firstName=Bat, lastName=Man], User [age=35, firstName=Robin, lastName=Hood], User [age=30, firstName=Super, […]

Read More

Tags: , , , , ,

by , on January 30th, 2017

  • Categories