簡體   English   中英

Java:從列表中刪除以其他列表中的元素開頭的元素

[英]Java : remove from list elements that start with elements from other list

有沒有辦法做類似的事情:

words.removeIf(specialWords::contains);

但是通過用“startWith”替換“contains”

我會嘗試以下操作:

words.removeIf(value -> specialWords.stream().anyMatch(value::startsWith));

這應該從以任何specialWords開頭的words中刪除每個項目。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM