直接求重复算了,简单明了
@Test
public void setTest(){
Set<Integer> one = Sets.newHashSet(1,2,3);
Set<Integer> two = Sets.newHashSet(1,4,3);
List<Set<Integer>> list = Lists.newArrayList(one,two);
Set<Integer> three = list.stream().flatMap(Collection::stream).filter(predicate()).collect(Collectors.toSet());
System.out.println(three);
}
private Predicate<Integer> predicate(){
Set<Integer> set = Sets.newHashSet();
return i->!set.add(i);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…