从包含特定子字符串的arraylist元素中删除特定字符串 [英] Remove specific string from arraylist elements containing a particular subsrtring

查看:164
本文介绍了从包含特定子字符串的arraylist元素中删除特定字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的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 containslefrom 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"));

这篇关于从包含特定子字符串的arraylist元素中删除特定字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆