This is a simple example to remove Duplicates from a Collection.
The Strategy followed involves :
1) Copy the elements to a Set.
2) This causes all the duplicates to be eliminated.
3) Clear the List
4) Copy the contents of the Set to the List
I have also added a simple sort .
Hope this post is useful
___________________________________________________________________________________
public class Main {
public static void removeDuplicates(List objects){
Set
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment