当前位置:网站首页>分析list中有无重复数据且重复了几次
分析list中有无重复数据且重复了几次
2022-06-28 11:08:00 【soha_dong】
有一个List中存储了很对bean对象 ,
List<CarPeccancy.ROWSDETAILBean> list = peccancy.getROWS_DETAIL();
其中每个bean的数据又是不相同的,要根据bean的name属性来判断是否有重复的数据。
这时我们再创建一个新的List集合存储name属性的值
List<String> carList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
carList.add(list.get(i).getCarnumber());
}
统计每个name出现的次数
int number = 0;
int not = 0;
for (String temp : carList) {
int frequency = Collections.frequency(carList, temp);
if (frequency > 1) {
number++;
} else {
not++;
}
}
System.out.println("重复数据:" + number);
System.out.println("无重复数据:" + not);
边栏推荐
- Secretary of the Ukrainian national security and National Defense Commission: will carry out precision strikes against targets in Russia
- Basic 02: variable, remember the mobile number of the object
- 【实操】Appium Settings app is not running after 5000ms
- GEE:基于 MCD64A1 的 GlobFire 日常火灾数据集
- [semidrive source code analysis] [x9 chip startup process] 32 - play module analysis - RTOS side
- 近况
- Wireshark数据抓包分析之FTP协议
- MySQL (III)
- 【agora】get 一个 agora_refptr 对象的用法示例
- ProCAST有限元铸造工艺模拟软件
猜你喜欢
随机推荐
Datetime and logging module
Introduction to GDB
Makefile简介
JS foundation 6
sentinel
GDB简介
Threads and thread pools
论文阅读 (59):Keyword-Based Diverse Image Retrieval with Variational Multiple Instance Graph
JS foundation 4
实体转JSON时,值为null的字段的丢失问题
JS foundation 3
合约量化交易系统开发 | 合约量化APP开发(现成案例)
拼接String集合中的字符串_基于Stream
Excel导入导出便捷工具类
Scientific research - web of science retrieval skills
JS基础2
Information hidden in the trend chart of Hong Kong London gold market
NFT卡牌链游系统开发dapp搭建技术详情
Move command
[practice] appium settings app is not running after 5000ms