Skip to content

Instantly share code, notes, and snippets.

@CeeFeS
Created November 10, 2020 10:58
Show Gist options
  • Save CeeFeS/04a757fdea4f075144cb566771921b3e to your computer and use it in GitHub Desktop.
Save CeeFeS/04a757fdea4f075144cb566771921b3e to your computer and use it in GitHub Desktop.
clear list from duplicate individual elements
private List<?> clearListFromDuplicates(List<?> list1) {
Map<String, ?> cleanMap = new LinkedHashMap<String, ?>();
for (int i = 0; i < list1.size(); i++) {
cleanMap.put(list1.get(i)./**existing, double element*/, list1.get(i));
}
List<?> list = new ArrayList<?>(cleanMap.values());
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment