List<String> gatherTimeList = eSResponseList.stream() .map(DevPortReportEsDTO::getGatherTime) // 获取目标字段的值 .distinct() // 去重 .collect(Collectors.toList()); // 转为列表 改成set集合
时间: 2024-02-21 20:57:06 浏览: 21
你的问题是将上述代码中的列表转换为集合,正确吗?
如果是的话,可以将最后一行的代码改为:
```
.collect(Collectors.toSet()); // 转为集合
```
这样就可以将列表转换为集合并去重。