主要用到Java 8的Stream类

 

    long distinctedSize = list.stream().distinct().count();
    boolean hasRepeat = list.size() > distinctedSize;

 

如果List<E>中的E是个自定义的POJO,那么最好重写其toString()方法。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-10-06
  • 2022-12-23
  • 2021-07-06
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-01-14
  • 2021-11-18
相关资源
相似解决方案