我有2个List
List<Obligation>,List<ObligationStatus> 结构如下:
public class Obligation {
private String topic;
private String status;
private String comment;
private String text;
}
和
public class ObligationStatus {
private String topic;
private String status;
private String comment;
}
status里面是所有元素, 填充在 我想设置的comment和从每个元素到每个元素的基础上。List<Obligation>null
topiclist
statuscommentList<ObligationStatus>List<Obligation>topic
// this is what i have tried, and is working fine
obList.stream().forEach(ob -> {
osList.stream().forEach(os -> {
if (ob.getTopic().equalsIgnoreCase(os.getTopic())) {
ob.setStatus(os.getStatus());
ob.setComment(os.getComment());
}
});
});
// also tried to do this without using forEach, but compilation error here
List<Obligation> result = obList.stream()
.map(ob -> osList.stream().map(os -> os.getTopic().equals(ob.getTopic())).collect(Function.identity()))
.collect(Collectors.toList());
我们可以不起诉就这样做吗forEach?
任何信息都会有帮助。
30秒到达战场
万千封印
相关分类