List<String> str=new ArrayList<>();

str.add("a");

str.add("a");

str.add("b");

long count=str.stream().distinct().count();//去重后,元素的个数

count<str.size()  为true  表示存在相同元素   ,flase 表没有相同元素;

也可以转set判断

相关文章: