Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gedankennebel/7875589 to your computer and use it in GitHub Desktop.
Save gedankennebel/7875589 to your computer and use it in GitHub Desktop.
Static method to get a duplicate free implementation of List
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