How to sort a list of objects for duplicates in java?basically that every object should be uniqe in list after sorting. Maybe someone knows a good example.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can add the elements of the List to a Set, and then create a new List with those elements, like this:
Be aware that:
Objectas the type for the List and Set, replace it with the appropriate type to suit your needshashCodeandequals