list.stream().distinct().count()
时间: 2023-08-19 14:12:59 浏览: 125
list.stream().distinct().count()的作用是对列表进行去重,并返回去重后的元素数量。\[1\]这个方法会根据对象的hashCode()和equals()方法来判断元素是否重复。如果全部字段值都一样的对象才会被去重,部分字段一样的对象不会被去重。\[1\]这个方法返回的是一个long类型的值,表示去重后的元素数量。
#### 引用[.reference_title]
- *1* [Java8 list.stream()操作使用心得](https://blog.csdn.net/diyangxia/article/details/125519699)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [jdk 8新特性 List.stream() .distinct() 去重 List中对象 多条件去重](https://blog.csdn.net/qq_41080067/article/details/118518696)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Java 8 Stream.distinct() 列表去重示例](https://blog.csdn.net/haiyoung/article/details/80934467)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文