假设一个List里面包含多个List:<"apple", "banana">,<"ball", "pen"> <"apple", "orange">, <"grape", "orange">,<"paper","ruler">,<"ink","pen">如何将每个List进行重复比对,并将含有相同元素的List合并,最后形成一个新的List>:<"apple","banana","orange","grape">,,<"paper","ruler">也可理解为:"A=B","C=D","A=E","F=E","G=H","I=D" => "A=B=E=F","C=D=I","G=H"请诸位不吝指教,谢谢!
3 回答
翻过高山走不出你
TA贡献1875条经验 获得超3个赞
(1)Colletions.disjoint来判断是否有交集
(2)在有交集的时候进行合并,合并的时候转换为不重复的集合类Set,使用Set的addAll方法合并
添加回答
举报
0/150
提交
取消