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 + '}';
}

两个自定义对象List列表取交集(intersection)的更多相关文章

  1. python的列表综合list-comprehension示例,及两列表取补集

    两个目的: 1. 了解了python的list comprehesion的用法 2. 了解了两个列表取交集和补集的方法 R语言取交集和补集更简单,直接有函数. perl 稍麻烦一些, 关键是用hash ...

  2. Python 关于拷贝(copy)汇总(列表拷贝 // 字典拷贝 // 自定义对象拷贝)

    1.列表拷贝 引用是指保存的值为对象的地址.在 Python 语言中,一个变量保存的值除了基本类型保存的是值外,其它都是引用,因此对于它们的使用就需要小心一些.下面举个例子: 问题描述:已知一个列表, ...

  3. c#得出两个列表的交集

    c#提供了Intersect来得到两个列表的交集,它是通过使用默认的相等比较器对值进行比较生成两个序列的交集,定义为: public static IEnumerable<TSource> ...

  4. Java:集合,对列表(List)中的自定义对象按属性(字段)排序(正序、倒序)的方法

    1. 要求 对列表(List)中的自定义对象,要求能够按照对象的属性(字段)进行排序(正序.倒序). 如:用户对象(Member)有用户名(username).级别(level).出生日期(birth ...

  5. Map集合的遍历方式以及TreeMap集合保存自定义对象实现比较的Comparable和Comparator两种方式

    Map集合的特点 1.Map集合中保存的都是键值对,键和值是一一对应的 2.一个映射不能包含重复的值 3.每个键最多只能映射到一个值上 Map接口和Collection接口的不同 Map是双列集合的根 ...

  6. iOS开发——UI进阶篇(十一)应用沙盒,归档,解档,偏好设置,plist存储,NSData,自定义对象归档解档

    1.iOS应用数据存储的常用方式XML属性列表(plist)归档Preference(偏好设置)NSKeyedArchiver归档(NSCoding)SQLite3 Core Data 2.应用沙盒每 ...

  7. [Swift]LeetCode986. 区间列表的交集 | Interval List Intersections

    Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order ...

  8. Python进阶:自定义对象实现切片功能

    2018-12-31 更新声明:切片系列文章本是分三篇写成,现已合并成一篇.合并后,修正了一些严重的错误(如自定义序列切片的部分),还对行文结构与章节衔接做了大量改动.原系列的单篇就不删除了,毕竟也是 ...

  9. JS中的函数,Array对象,for-in语句,with语句,自定义对象,Prototype

    一)函数 A)JS中的函数的定义格式: function add(a,b) { var sum = a+b; document.write("两个数的和是:" + sum); // ...

随机推荐

  1. 商业web漏扫神器——appscan篇

      版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/dongfei2033/article/details/78472507 很快,已经到了三大商业漏 ...

  2. python测试开发django-20.添加创建时间DateTimeField

    前言 我们在admin后台发布一篇文章的时候,一般会有创建时间和最后更新时间这2个字段,创建时间就是第一次编辑文章的时候自动添加的,最后更新时间就是每次修改文章的内容后自动更新 在models.py建 ...

  3. Kubernetes基础:查看状态、管理服务

    目标 了解Kubernetes Pod 了解Kubernetes Node 学习如何调试部署问题 了解如何通过Service暴露应用 Kubernetes Pods 在Kubernetes中创建一个D ...

  4. 在Visual Studio 2013里使用 Microsoft SQL Server Compact Edition

    (1)下载SQLCE组件 https://www.microsoft.com/en-us/download/details.aspx?id=17876 (2)下载VS2013工具设计器 https:/ ...

  5. Maven 搭建spring boot多模块项目(附源码),亲测可以,感谢原创

    原创地址:https://segmentfault.com/a/1190000005020589 我的DEMO码云地址,持续添加新功能: https://gitee.com/itbase/Spring ...

  6. 一种多线程写日志文件的解决方案 c#源代码演示

    using System;using System.Collections.Generic;using System.Collections;using System.Text;using Syste ...

  7. iOS:CoreText的常用语法

    CoreText的关键语法 一.坐标旋转 -(void)drawRect:(CGRect)rect { //获取上下文 CGContextRef ctx = UIGraphicsGetCurrentC ...

  8. swift3.0:CoreData的使用

    一.介绍 CoreData不像slqite3那样编写代码繁琐,同时避免了使用了SQL语句的麻烦,也可以回避使用C语言的语法,降低了iOS开发的技术门槛. CoreData可降低开发成本,提高代码质量. ...

  9. Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program

    今天同事在一个服务器(winserver 2008 x64)上新建了一个IIS(7) 网站,但是报了如下错误: Could not load file or assembly 'System.Data ...

  10. springboot的Web开发-Web相关配置

    一:Spring Boot提供自动配置 通过查看WebMvcAutoConfiguration及WebMvcProperties的源码,可以发现Spring Boot为我们提供了如下的自动配置. 1, ...