/**
*Copyright 2017 Yonyou Corporation Ltd. All Rights Reserved.
* This software is published under the terms of the Yonyou Software
* License version 1.0, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*
* @Project Name : dmsgms.customer
*
* @File name : Test.java
*
* @Author : sunduoduo
*
* @Date : 2017年10月19日
*
----------------------------------------------------------------------------------
* Date Who Version Comments
* 1. 2017年10月19日 sunduoduo 1.0
*
*
*
*
----------------------------------------------------------------------------------
*/
package com.yonyou.dmsgms.customer.service.member;
import java.util.ArrayList;
import java.util.List;
/**
* TODO description
* @author sunduoduo
* @date 2017年10月19日
*/
public class Test {
/**
* TODO description
* @author sunduoduo
* @date 2017年10月19日
* @param args
*/
public static void main(String[] args) {
//頁面
List<Integer> list2 = new ArrayList<Integer>();
list2.add(1);
list2.add(2);
list2.add(3);
list2.add(4);
//數據庫
List<Integer> list3 = new ArrayList<Integer>();
list3.add(3);
list3.add(4);
list3.add(5);
list3.add(6);
//需要添加的
List<Integer> add = new ArrayList<Integer>(list2);
add.removeAll(list3);
System.out.println(add);
//需要更新的
List<Integer> update = new ArrayList<Integer>(list2);
update.retainAll(list3);
System.out.println(update);
//需要刪除的
List<Integer> del = new ArrayList<Integer>(list3);
del.removeAll(list2);
System.out.println(del);
}
}
獲取兩個list的交集和兩個list中雙方分別不包含的集合
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.