对比两个数组的

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, 2]

发表评论

邮箱地址不会被公开。 必填项已用*标注