当前位置:网站首页>分析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);边栏推荐
猜你喜欢

Katalon framework tests web (XX) custom keywords and upload pop-up operations

Docker modifies the user name and password of MySQL

动态库(共享库)的制作和使用

Making and using of static library

Katalon global variable is referenced in testobject

Wealth management for programmers

String & heap & method area

Word、PDF、TXT文件实现全文内容检索需要用什么方法?

JS基础3

Realization of a springboard machine
随机推荐
知道 Redis RDB 这些细节,可以少踩很多坑
Docker modifies the user name and password of MySQL
GCC introduction
毕业了
【实战】1364- 实现一个完美的移动端瀑布流组件(附源码)
BigDecimal 类的 compareTo() 和 equals()方法
远程登录sshd服务
壓縮解壓
Décompression par compression
Mysql database overview and installation process
Convert the file URL in the browser to a file stream
Xshell and xftp tutorial
Summary of spatial temporal time series prediction modeling methods
JS foundation 3
Threads and thread pools
How to use output in katalon
Word、PDF、TXT文件实现全文内容检索需要用什么方法?
Yann LeCun新论文:构建自动智能体之路
数据库系列:有什么办法对数据库的业务表进行无缝升级
How to use K-line diagram for technical analysis