<span class="keyword" style="background-color: rgb(250, 250, 250); font-size: 1em; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace;">boolean</span><span style="color: black; background-color: rgb(250, 250, 250); font-size: 1em; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace;"> retainAll(Collection<?> c); </span>
<pre name="code" class="html">List<Employee> <span style="font-family: Arial, Helvetica, sans-serif;">employeeOfIntermediarys </span><span style="font-family: Arial, Helvetica, sans-serif;">= new ArrayList<Employee>(); </span><pre name="code" class="html">List<Employee> <span style="font-family: Arial, Helvetica, sans-serif;">tempList </span><span style="font-family: Arial, Helvetica, sans-serif;">= new ArrayList<Employee>();</span>
if(tempList != null){
<span style="white-space:pre"> </span>//去掉<span style="font-family: Arial, Helvetica, sans-serif;">tempList 中与</span><span style="font-family: Arial, Helvetica, sans-serif;">employeeOfIntermediarys 中</span>相同的元素,在合并
List<Employee> eoiList = new ArrayList<Employee>(employeeOfIntermediarys);
if (eoiList.retainAll(tempList)) {
tempList.removeAll(eoiList);
}
employeeOfIntermediarys.addAll(tempList); }
public class Book {
private int id;
private String nameString;
private String writer;
public Book(){
id= -1;
nameString = "";
writer = "";
}
List<Book> books = new ArrayList<Book>();
List<Book> tempList = new ArrayList<Book>();
Book book1 = new Book();
book1.setId(1);
book1.setNameString("dkjdf");
Book book2 = new Book();
book2.setId(2);
book2.setNameString("到加福禄寿");
Book book3 = new Book();
book3.setId(3);
book3.setNameString("dj地方");
Book book4 = new Book();
book4.setId(4);
book4.setNameString("dkjdf");
Book book5 = new Book();
book5.setId(5);
book5.setNameString("到加福禄寿");
Book book6 = new Book();
book6.setId(6);
book6.setNameString("dj地方");
books.add(book1);
books.add(book2);
books.add(book5);
books.add(null);
tempList.add(book1);
tempList.add(book4);
tempList.add(null);
tempList.retainAll(books);
System.out.println(tempList.get(0).booktoString());
@Override
public boolean equals(Object c){
if (!(c instanceof Employee)) {
return false;
}
Employee eoi = (Employee) c;
if (eoi.getUserGuid().equals(userGuid)) {
return true;
}
return false;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有