小编Ank*_*dev的帖子

在lambda foreach表达式java 8中获取索引

我想从某个过滤器上的列表中删除对象,并且有多个对象.

list.stream().filter(g->g.getName().equalsIgnoreCase("String")).forEach(result ->{

            /* is it possible to get the index of the result here?
            .remove(), will iterate through the list again. I don't want that.
            */

            list.remove(result);
});
Run Code Online (Sandbox Code Playgroud)

java foreach lambda arraylist java-8

0
推荐指数
1
解决办法
6177
查看次数

标签 统计

arraylist ×1

foreach ×1

java ×1

java-8 ×1

lambda ×1