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

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 中不包含的值。

原文地址:https://www.cnblogs.com/R4mble/p/8408265.html