核心代码如下:

List<String> result = Stream.of(Lists.newArrayList("A", "B", "C"), Lists.newArrayList("A", "B"))
  .flatMap(Collection::stream).distinct().collect(Collectors.toList());

最终的结果输出是A B C。

应用场景:
有些时候我们需要合并两个返回类型相同的结果集,就可以用这个,不必SQL查询合并结果。

相关文章:

  • 2018-03-13
  • 2021-10-16
  • 2021-12-03
  • 2021-12-25
  • 2021-12-25
  • 2021-05-08
  • 2021-11-19
  • 2022-01-01
猜你喜欢
  • 2022-01-04
  • 2021-12-03
  • 2021-12-03
  • 2021-12-03
  • 2021-12-03
  • 2021-12-03
  • 2021-12-03
  • 2021-12-03
相关资源
相似解决方案