首页 > 编程语言 > 详细

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

时间:2018-02-03 10:29:50      阅读:190      评论:0      收藏:0      [点我收藏+]
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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!