从包含特定子字符串的数组列表元素中删除特定字符串 [英] Remove specific string from arraylist elements containing a particular subsrtring
本文介绍了从包含特定子字符串的数组列表元素中删除特定字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的 arrayList 代码,
Here is my code for arrayList ,
String[] n = new String[]{"google","microsoft","apple"};
final List<String> list = new ArrayList<String>();
Collections.addAll(list, n);
如何从上面的列表中删除所有包含le
的元素.
是否有任何默认方法或通过循环我们必须手动删除.告诉我如何做.谢谢.
how to remove all the elements that containsle
from the above list.
Is there any default method or by looping we have to remove manually.tell me how to do it.Thanks.
推荐答案
从 java 8 可以使用
From java 8 You can use
list.removeIf(s -> s.contains("le"));
这篇关于从包含特定子字符串的数组列表元素中删除特定字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文