zoukankan      html  css  js  c++  java
  • 两个自定义对象List列表取交集(intersection)

        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 + '}';
        }
        
  • 相关阅读:
    Python网络爬虫——bs4基本用法
    Python网络爬虫——requests模块(1)
    yii gii配置ip限制使用gii
    openfire连接数据库mysql
    js 提示条
    jquery滚动条平滑滑动
    yii2.0 添加组件baidu ueditor
    yii添加验证码 和重复密码
    css图标库 font-awesome.min.css
    yii配置访问路由权限配置
  • 原文地址:https://www.cnblogs.com/yshyee/p/8244752.html
Copyright © 2011-2022 走看看