(五)返回两个数组之间的差异

public static int[] difference(int[] first, int[] second) {
    Set<Integer> set = Arrays.stream(second).boxed().collect(Collectors.toSet());
    return Arrays.stream(first)
            .filter(v -> !set.contains(v))
            .toArray();
}

 只保留 b 中不包含的值。

posted @ 2018-02-03 01:57  R4mble  阅读(160)  评论(0编辑  收藏  举报