java for循环删除使用迭代器

      Iterator iterator=hongBaoJuntanData.iterator();
            while (iterator.hasNext()){
                ProductJunTanData item=(ProductJunTanData)iterator.next();
                //判断该商品的活动Id是否包含再红包的指定活动列表中
                if (StringUtils.isNotEmpty(promoIds)&&!(',' + promoIds + ',').contains("," + item.getPromotionId() + ",") && !(isCommon && item.getPromotionId() == 0)) {
                    iterator.remove();
                }
                //判断该商品Id是否包含再红包的品类列表中
                if (StringUtils.isNotEmpty(productIds)&&!(',' + productIds + ',').contains("," + item.getId() + ",")) {
                    iterator.remove();
                }
                //判断该商品Id是否包含再红包的品类列表中
                if (StringUtils.isNotEmpty(brandProductIds)&&!(',' + brandProductIds + ',').contains("," + item.getId() + ",")) {
                    iterator.remove();
                }
            }
原文地址:https://www.cnblogs.com/cxxiao/p/12465943.html