多个数组列表的逻辑连接

编程入门 行业动态 更新时间:2024-10-26 16:25:59
本文介绍了多个数组列表的逻辑连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

有多个arraylists(arraylists的数量是先验未知的).在每个数组列表中,我需要找到一个元素,该元素提供与来自其他列表的元素的逻辑连接.请注意,仅对非空值进行比较.

There are multiple arraylists (the number of arraylists is apriori unknown). In each arraylist I need to find an element that provides logical conjunction with elements from other lists. Note that the comparison is made only for non-null values.

ArrayList<Integer[]> list1 = new ArrayList<Integer[]>();
ArrayList<Integer[]> list2 = new ArrayList<Integer[]>();
ArrayList<Integer[]> list3 = new ArrayList<Integer[]>();

list1.add(new Integer[]{1,2,3,4});
list1.add(new Integer[]{1,4,5,6});

list2.add(new Integer[]{1,4,null,null});

list3.add(new Integer[]{null,null,null,5});
list3.add(new Integer[]{null,null,null,6});

在这种情况下,答案应该是:

In this case the answer should be:

list1: {1,4,5,6}
list2: {1,4,null,null}
list3: {null,null,null,6}

由于数组列表的数量是先验未知的,所以我想使用递归.但是,也许有更简单的解决方案?

Since the number of arraylists is apriori unknown, I thought to use recursion. However, perhaps there might be simpler solutions?

推荐答案

听起来您可能想要使用 Google 出色的 番石榴库.查看集合类.

Sounds like you might want to use Google's excellent guava-libraries. Check out the Sets class.

这篇关于多个数组列表的逻辑连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-16 07:44:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/881960.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   数组   逻辑   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!