ArrayList<String> oldList = Lists.newArrayList();
oldList.add("备用1");
oldList.add("备用2");
oldList.add("备用3");
oldList.add("备用4");
oldList.add("备用5");
List<List<String>> ccc =new ArrayList<>();
ccc.add(oldList);
如何使用stream将"备用3"换成其他元素。
我之前的写法如下,请问这种写法问题是出在哪里:
ccc.stream().forEach(t->{
t.stream().map(k->{
if ("备用5".equals(k)) {
k = "sss";
}
return k;
}).collect(Collectors.toList());
});