Can Java 8 Streams operate on an item in a collection, and then remove it?

前端 未结 8 1328
不知归路
不知归路 2020-12-23 14:22

Like just about everyone, I\'m still learning the intricacies (and loving them) of the new Java 8 Streams API. I have a question concerning usage of streams. I\'ll provide a

8条回答
  •  爱一瞬间的悲伤
    2020-12-23 14:51

    if I understand your question correctly:

    set = set.stream().filter(item -> {
        if (item.qualify()) {
            ((Qualifier) item).operate();
            return false;
        }
        return true;
    }).collect(Collectors.toSet());
    

提交回复
热议问题