package vc;
import java.util.ArrayList;
import java.util.List;
public class ListDemo {
public static void main(String [] args){
ArrayList table1 = new ArrayList();
table1.add("chen");
table1.add("wang");
table1.add("liu");
table1.add("zhang");
System.out.println("表1内容" + table1);
ArrayList table2 = new ArrayList();
table2.add("chen");
table2.add("hu");
table2.add("zhang");
System.out.println("表2内容" + table2);
ArrayList table3 = new ArrayList();
table3.clear();
table3.addAll(table1);
table3.retainAll(table2);
System.out.println("两个线性表的交集为:" + table3); //求交集
table3.clear();
table3.addAll(table1);
table3.addAll(table2);
System.out.println("两个线性表的并集为:" + table3); //求并集合
}
}