[英]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.