[英]Java : remove from list elements that start with elements from other list
Is there a way to do something like:有没有办法做类似的事情:
words.removeIf(specialWords::contains);
But by replacing "contains" by "startWith"但是通过用“startWith”替换“contains”
I would try the following:我会尝试以下操作:
words.removeIf(value -> specialWords.stream().anyMatch(value::startsWith));
This should remove every item from words
that start with any of the specialWords
.这应该从以任何specialWords
开头的words
中删除每个项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.