两个自定义对象List列表取交集(intersection)
2024-10-13 04:19:26
public static void main(String[] args) {
List<Fpxx> list = ListUtils.intersection(getFpList1(), getFpList2()); for(Fpxx fp:list){
System.out.println(fp);
} System.out.println("size:"+list.size());
} public static List<Fpxx> getFpList1() {
List<Fpxx> list = new ArrayList<Fpxx>();
for(int i=100000;i<200000;i++){
Fpxx fp = new Fpxx();
fp.fpdm = "0223678";
fp.fphm = "3"+i; list.add(fp);
} return list;
} public static List<Fpxx> getFpList2() {
List<Fpxx> list = new ArrayList<Fpxx>();
for(int i=199900;i<199910;i++){
Fpxx fp = new Fpxx();
fp.fpdm = "0223678";
fp.fphm = "3"+i; list.add(fp);
} return list;
}
} class Fpxx {
public String fpdm;
public String fphm; @Override
public int hashCode() {
int hash = 3;
return hash;
} @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Fpxx other = (Fpxx) obj;
if ((this.fpdm == null) ? (other.fpdm != null) : !this.fpdm.equals(other.fpdm)) {
return false;
}
if ((this.fphm == null) ? (other.fphm != null) : !this.fphm.equals(other.fphm)) {
return false;
}
return true;
} @Override
public String toString() {
return "Fpxx{" + "fpdm=" + fpdm + ", fphm=" + fphm + '}';
}
最新文章
- C#中操作Word(1)—— word对象模型介绍
- ORM框架
- IAP 程序内购
- js生成 1-100 不重复随机数
- Oracle系列之游标
- Struts的ONGL
- SqlServer发送邮件,定时作业
- hdu_5783_Divide the Sequence(贪心)
- Java多线程之线程的创建
- jdk 环境配置踩坑
- [Mac] mac linux 多线程下载利器 axel
- webpack入门教程--1
- 问题:怎么把mysql的系统时间调整为电脑的时间?(已解决)
- Hadoop生产环境配置文件
- AX_UserInfo
- 第一个OC的类
- php 连接redis
- C++ 模板详解 肥而不腻
- [转]php中实现事件驱动
- Linq To Object多字段组合唯一校验
热门文章
- sharepoint 2013 网站集解锁
- win7 64位系统及开发环境重装后的总结
- Android tips(八)-->;Android Studio打包apk,aar,jar包
- ExtJS 4.2 教程-02:bootstrap.js 工作方式
- 用开源项目RangBar来实现有范围的SeekBar
- Spring MVC 返回类型为字符串时, 返回中文变成";?";处理
- MultipleRegularExpressionAttribute MVC中扩展自定义验证规则
- The node (XXX.XXX.XXX.XXX,XXX.XXX.XXX.XXX)has already some ScaleIO components installed
- Java 读取某个目录下所有文件、文件夹
- 大数据开发实战:Hive表DDL和DML