Search Java Code Snippets

  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.

#Java - Code Snippets for '#Remove duplicates from list' - 2 code snippet(s) found

 Sample 1. Method to remove duplicates from a Map ( string and List of objects ) by matching the member field of the object.

Map<String,List<ClassInfoBean>> removeDuplicates(Map<String, List<ClassInfoBean>> interfaceMap){
   Map<String, List<ClassInfoBean>> interfaceMapWithoutDuplicate = new HashMap();
   for(Map.Entry<String, List<ClassInfoBean>> entry: interfaceMap.entrySet()){
      List<ClassInfoBean> classListWithoutDuplicate = new ArrayList();
      boolean alreadyContain = false;
      for(ClassInfoBean classes: entry.getValue()){
         for(ClassInfoBean classes1: classListWithoutDuplicate){
               alreadyContain = true;
         if(alreadyContain == false){
      interfaceMapWithoutDuplicate.put(entry.getKey(), classListWithoutDuplicate);
   return interfaceMapWithoutDuplicate;

   Like      Feedback     map  map of list of objects  remove duplicates from map  Map.Entry

 Sample 2. Method to remove duplicates from a List of objects by matching the member elements of objects.

List<ClassInfoBean> removeDuplicates(List<ClassInfoBean> listClassInfo){
   Set<ClassInfoBean> set = new HashSet();
   Set<String> url = new HashSet();
   boolean flag = false;
   for(ClassInfoBean cl: listClassInfo){
   return new ArrayList(set);

   Like      Feedback     list  list of objects  remove duplicates from list

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner