对比两个数组,删除其中一个数据的交集数据

测试代码:

1
2
3
4
5
6
7
8
9
10
public static void main(String\[\] args) {
String\[\] s1 = {"1","2","3","4"};
String\[\] s2 = {"3","4","5","6"};

TreeSet ts1 = new TreeSet(Arrays.asList(s1));

ts1.removeAll(Arrays.asList(s2));

System.out.println(ts1);
}

输出:

1
[1, 2]