Created
December 9, 2013 16:46
-
-
Save gedankennebel/7875589 to your computer and use it in GitHub Desktop.
Static method to get a duplicate free implementation of List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> List<T> getDuplicateFreeList(List<T> list) { | |
List<T> duplicateFreeList = new ArrayList<>(); | |
if (list != null) { | |
for (T listEntry : list) { | |
if (!duplicateFreeList.contains(listEntry)) { | |
duplicateFreeList.add(listEntry); | |
} | |
} | |
} | |
return duplicateFreeList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment